ah, the fundamentals. what conditions would make it false?
- if the string lengths are not the same. - if the character at the given string index is not equal to the character at the same index for the other string if it passes the two tests above then the strings are equal. what about case sensitivity? On Thu, Dec 11, 2008 at 3:38 PM, [email protected] <[email protected]>wrote: > > Currently i'm learning to use C# at school. > Last lesson I had learned about strings, and got some homework to get > done. > So here it is : > 1) Make a function that will get two strings, check if they are the > same, and then return false\true. (The teacher said "DO NOT USE > STRING.COMPARE"). I tried do this one using FOR, but I always get out > of the index bounds. (here is my function) : > static bool GetNCheck(string s, string p) > { > int o = s.Length-1; > int i = 0; > if (s[s.Length - 1] < p[p.Length - 1]) > o = p.Length - 1; > for (; s[i] == p[i] && i < o; i++) ; > if (i == s.Length-1 && i == p.Length-1) > return true; > return false; > } > > 2)MAke a function that get a string, check if it have any numbers in > it, and then return false\true. > > thanks :D > -- Charles A. Lopez [email protected] Bachelor of Arts - Computer Science New York University Registered Microsoft Partner New York City, NY
