Alternative to using InStr

后端 未结 2 891
遇见更好的自我
遇见更好的自我 2020-12-19 03:10

how can I use a different function \"InStr\" this is the code that I am using and works fine but moving away from InStr is my goal

i = InStr(1, Hostname, Env         


        
2条回答
  •  庸人自扰
    2020-12-19 03:45

    If you need equivalent C# code you can use Strings class from Microsoft.VisualBasic assembly, thus code can be like following:

    using Microsoft.VisualBasic;
    . . . 
    i = Strings.InStr(1, Hostname, Environment.NewLine);
    

    enter image description here

    Another approach is using appropriate String.Indexof function.

    Links:

    • http://msdn.microsoft.com/en-us/library/8460tsh1.aspx
    • http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.strings.aspx
    • http://msdn.microsoft.com/en-us/library/k8b1470s.aspx

提交回复
热议问题