|
Random rand = new Random();
string[] somestrings = { "Hello", "World", "From", "An", "Array" };
string randString = somestrings[rand.Next(somestrings.Length - 1)];
char[] characters = randString.ToCharArray();
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Before you start writing an ounce of code, make sure you have a game plan (i.e. psuedocode or flowchart) that expresses your logic. Once you're fairly certain your logic is correct, it'll be pretty easy to convert it to C# (or any other language).
You could start by posting your logic and we'd be happy to help you refine/verify it.
/ravi
|
|
|
|
|
I would do something like this.
public bool isMatch()
{
bool Matches = false;
string[] asCompare = new string[4];
asCompare.SetValue("First0", 0);
asCompare.SetValue("Second1", 1);
asCompare.SetValue("Third2", 2);
asCompare.SetValue("Fourth3", 3);
Random ran = new Random();
int iVal = ran.Next(asCompare.Length - 1);
string sValue = asCompare[iVal];
char[] chars = sValue.ToCharArray();
string sCharTracker = "";
for (int i = 0; i < chars.Length; i++)
{
sCharTracker = chars[i].ToString();
//Matches = //you would probably do your compare with a method call here//
}
return Matches;//This will be if it matches or not//
}
|
|
|
|
|
neptune2k wrote: Basically ive an array of strings and i want to randomly select a word out of this array
Once the word is selected i then need to split the word into separate characters, so I can check the users input against each letter until they finally guess the word
That's a one-liner.
char[] chars = (new string[] { "some","words","in","an","array" })[(new Random()).Next(5))].ToCharArray();
---
b { font-weight: normal; }
|
|
|
|
|
thanks guys, thats really helped, i get where i was going wrong now
i know where to come in future if i hit any problems
|
|
|
|
|
I want to know how to copy,cut & paste the selected text in a text editor.
can any one help me in this please.
|
|
|
|
|
By "text editor" do you mean a TextBox ? If so, see this[^] link.
/ravi
|
|
|
|
|
Hi!
I'm trying to create a custom conflict resolver for SQL Server 2000 in C# but
I can't seem to find any source code examples of where I can actually
see what needs to be done.
Any help is welcome
Thanks,
Taka Ataka
Taka
|
|
|
|
|
hello firend,
i'm getting the following exception:
An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll<br />
<br />
Additional Information: The UNC path should be of the form\\server\\share.
if anyone knows anything about it plz let me know at once.
awaiting ur reply
Saira
|
|
|
|
|
You are providing a path that is in the wrong format.
If you supply any information about what you are trying to do, or what your code looks like, it might be possible to say anything more specific than that.
---
b { font-weight: normal; }
|
|
|
|
|
I don't know how to change background color of selected cell in datagrid.
It looks bad (it's gray) and i want it white
The problem can be seen on this image:
http://www.codeproject.com/csharp/Custom_DataGridColumnStyl/Custom_DataGridColumnStyl.jpg
Help
абвгдежзийклмнопрстуфхцчшщъьюя
|
|
|
|
|
The problem is only when
grid.Readonly = true
ju
абвгдежзийклмнопрстуфхцчшщъьюя
|
|
|
|
|
Hi all
How can I retrieve the last inserted record identity in Oracle. In sql server it's SELECT @@IDENTITY but how do we do it in oracle.
Thanks,
Dylan
|
|
|
|
|
One way is to create a SEQUENCE, cl_entry_seq, query this sequence for the next value, cl_entry_seq.nextval, and store this value into a stored procedure variable, v_entry_key by executing:
select cl_entry_seq.nextval into v_entry_key from dual;
Then you use the value of v_entry_key as your identity value in your INSERT statement.
George
|
|
|
|
|
hi,
another way cld be
select max(columnname) from tablename
hope this helps
Nitin...
|
|
|
|
|
Hello,
I am in the middle of a eLearning System project. Now I want to initiate a Video Conferencing system between 2 computers. What is the most efficient way of achieving this. I was looking at few options.
Should I use DirectX OR GDI+? Can I use Flash to do the same?
Thanks
|
|
|
|
|
I am trying to pass an array of strings from C# to the .NET component
I created in Matlab. I am getting a compile time error in Visual
Studio telling me that it can't convert a string array to a MWArray.
I have tried performing explicit conversions, but none of them work.
Any help would be greatly appreciated.
Here is an example of what I am trying to do:
[C#]
using MathWorks.MATLAB.NET.Arrays;
using MyMatlabNet;
...
MyMatlabNetClass myclass = new MyMatlabNetClass();
...
string [] mydata;
myclass.somemethod(mydata);
I have tried (MWArray), (MWCharArray), (MWCellArray) and nothing
works (allows it to compile).
|
|
|
|
|
You'll have to look through the MatLab documentation to see if there are any examples on how to convert .NET strings to MatLab ones.
I have no idea what I just said. But my intentions were sincere.
|
|
|
|
|
The issue is with passing an array of strings, not just passing a string. And I have already looked through the documentation, and that is why I am asking here.
|
|
|
|
|
|
I am trying to automate a process in which we access a web site with a digital certificate and login/password. A web form is filled out and then submitted. I want to do a web request (POST) to submit the information, but do not know how to use the digital certificate and login/password authentication in code. Anyone have experience with something similar?
Thanks
|
|
|
|
|
yes, now pay me $100,000,000.99
|
|
|
|
|
I'm trying to figure out how to change an object name based on a increment value in a loop. For example: I have a loop that iterates 10 times and I want a new object created during each iteration (object1, object2, ..., object10). Can I append the incrementer value to the name of it somehow? Thanks!
--------------------
gkurts
|
|
|
|
|
Surely this would be better done using a collection, which creates the object during the loop? Example:
ArrayList list = new ArrayList();
for (int i = 0; i < 10; i++)
{
MyClass classInstance = new MyClass();
classInstance.Id = i;
list.Add(classInstance);
}
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thanks for the response. Actually, I tried something similar to that previously, but what I'm trying to do is to create classInstance1, classInstance2, etc. I have to add these to a control and if they're not uniquely named, then the previous one will be overwritten. I hope this makes some sense - I haven't worked with C# in quite a while.
|
|
|
|