随机选择一个数组C# [英] Randomly choose an array C#

查看:157
本文介绍了随机选择一个数组C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含一系列字符的6字符串数组。我希望能够做的是随机挑选一个数组,一旦其采摘后,会产生一个最终的字符串响应。我需要一个列表来做到这一点,或有另一种方式?

I have 6 string arrays that contain a series of characters. What I would like to be able to do is random pick an array and once its picked afterwards, will produce a final string response. Do I need a list to do this or is there another way?

这一切仅仅是使用一个随机变量的小阵锻炼。

All of this is just an small array exercise using a random variable.

我要指定这是一个控制台应用程序。

I should specify that this is a console application.

推荐答案

一个简单的办法是:让一个数组的数组。选择一个随机索引以获得阵列之一。创建该的引用,然后挑选每个成员需要。

A simple option would be: Make an array of the arrays. Pick a random index to get one of the arrays. Create a reference to this and then pick each member as needed.

这篇关于随机选择一个数组C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆