小编AKC*_*AKC的帖子

如何从单个函数返回多列表<>值?

尝试从单个函数返回2个List值

我正在使用此代码: -

public KeyValuePair<int, int> encrypt(string password)
    {
        List<int> key = new List<int>();
        List<int> code = new List<int>();
        /*
           do stuff, do some more stuff and go!
        */

        return new KeyValuePair<List<int>,List<int>>(key,code);
    }
Run Code Online (Sandbox Code Playgroud)

这里我试图返回2个List<int>值但发生错误.如何从单个函数返回2个列表值

UPDATE

答案是找到的,我们得到了2个正确的答案,这就是为什么我不只是选择一个因为两个工作都很好

HadiRj回答

通过Enigmativity回答

如果你想使用我的代码,那么这是它的正确版本: -

public KeyValuePair<List<int>, List<int>> encrypt(string password)
    {
        List<int> key = new List<int>();
        List<int> code = new List<int>();
        /*
           do stuff, do some more stuff and go!
        */

        return new KeyValuePair<List<int>,List<int>>(key,code);
    }
Run Code Online (Sandbox Code Playgroud)

c# function list keyvaluepair

3
推荐指数
1
解决办法
4424
查看次数

在 React-Native 中使用粗箭头函数更改 React.Component

是否可以仅使用粗箭头函数在其他 React.Component 上渲染 React.Component,在我的情况下使用 state 似乎没有必要,因为不需要关闭打开的组件。我试图实现在其他 React.Component 上渲染 React.Component 的最简单方法。

我正在尝试这样做:

<Button onPress={() => { return (<ShowOtherReactComponent/>); }} >Show OtherComponent</Button>
Run Code Online (Sandbox Code Playgroud)

这是调用<ShowOtherReactComponent/>我知道的,因为我从 constructor 但是调用了一个警报函数!什么都没有渲染。这是为什么?我怎样才能做到这一点?

PS:这种方法可能是错误的,但仍然想看看它是如何做到的。为科学。

javascript reactjs react-native react-native-android

2
推荐指数
1
解决办法
497
查看次数