c# help

okay so the prob is

theres an array

string[]fun it has random stuff reed from a txt

what i need to do is locate the first letters of every element of the fun array

ive got a "for" loop for this obviously

string[1].fun smth like that. i dont know how to define it
Comments
14
zeriouz problemz
If you've got an array of strings, select a string from the array: fun[x], and then select the first letter from that..

Google will answer that in about 3 seconds.
but how do you define the selection . string[1] of fun , and yeah i obviously google'd shit before i posted this topic and couldnt find anything :[
Parent
guess what ... ive gave another shot for google and found what i was searching for ^^.. thanks for help thou <3
Parent
Cool, I appreciate learning programming isn't easy when you start out, but if you have a problem it's 99% likely to be on google. Probably be worth learning how to google properly (I mean that seriously) if you are taking a course in it.
Parent
is it a 1 dimensional array?

in c, the index starts with 0
I don't fully get your question, 'first letters of element'? Just be a little more specific.
Maybe you mean something like this:

for (int i = 0; i < fun.Length; i++) {
string sentence = fun;

string one = sentence.Substring(0, 1); // gets the first character
string two = sentence.Substring(0, 2); // gets the first and second character

Console.WriteLine( one + " | " + two );
}

Let's say:
string[] fun = new string[2];
fun[0] = "Hello World";
fun[1] = "Number two";

Would output:
H | He
N | Nu

PS: What Mayni said, this is really basic stuff.
okay so...
ive got a string array full of words starting with the letters "s" and "a"
i need to put these words into a "for" loop which has a "if" inside it which will decide
that the actual words (i) have the "a" or the "s" as the first letter.
if s then im to change the letter colors to red
if a then blue :)

int i;
string szöveg,a="a",b="s",c="i";
string[] stuff1 = System.IO.File.ReadAllLines(@"c:\c#\stuff1.txt");
string[] stuff2 = System.IO.File.ReadAllLines(@"c:\c#\stuff2.txt");
for (i = 0; i <= 100; i++)
szöveg = melee;
{
if (szöveg[0] = a) Console.ForegroundColor = ConsoleColor.Green;

dont mind that the colors not match i was just messing around . stil its not working i cant define how it should find the FIRST letter of the stuff1

it should look like szöveg[0].stuff1 in pascal or smth like that
Parent
off top of my head

for(int i = 0; i < s.Length; i++)
{
if(s == ' ')
{
if(s[i+1] == 'a')
{
// do something
}
else if(s[i+1] == 's')
{
// do something else
}
}
}
Parent
wanna bypass tzac? not that hard, pm me..
this journal could use some more python :>
Back to top