Eng Posted May 12, 2004 Posted May 12, 2004 Hi All, I am trying to convert my VB.NET to C# (for learning purpose) and I cannot seem to find the equivalent functions for Instr() and Mid() that I had used in VB.NET to be applied to C#. Can anyone tell me what the functions are to do those two functions in C#? InStr() ==> This function looks for a string within another string and returns the position where a match is found. Mid() ==> This function function returns a specified number of characters from a string beginning at a given point. Thanks in advance! Quote
Administrators PlausiblyDamp Posted May 12, 2004 Administrators Posted May 12, 2004 Mid can be replaced with .SubString and InStr with .IndexOf string s = "hello world"; int i = s.IndexOf("w"); //i=6 string s2 = s.Substring(2,4); //s2="llo " However these are not C# functions, they are intrisic to the .Net framework and you should also be using these from VB.Net rather than the legacy VB6 functions. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Eng Posted May 12, 2004 Author Posted May 12, 2004 Thank you. Boy...there is just too much to keep up with even when I think I know VB, VB.NET is a different world. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.