locked
Get Everything To Left Of Variable RRS feed

  • Question

  • I know you can use the below to get everything to the left of the ,

    string name =  filename.Substring(0, filename.IndexOf(','));

    but if I use 

    string name =  filename.Substring(0, filename.IndexOf(ses));

    I get a compile error of:

    IndexOf is missing a stringn comparison argument.

    Sunday, October 14, 2018 6:25 PM

Answers

  • Hi,

    try this:

    string name =  filename.Substring(0, filename.IndexOf(ses, StringComparison.CurrentCulture));

    Greetings, Chris

    Sunday, October 14, 2018 7:51 PM

All replies

  • Hi,

    try this:

    string name =  filename.Substring(0, filename.IndexOf(ses, StringComparison.CurrentCulture));

    Greetings, Chris

    Sunday, October 14, 2018 7:51 PM
  • Hello, 

    IndexOf() are expected a single parameter of Char type.

    So, you need to declare 

    Char ses;

    If you use a String type - you need a second argument as DerChris88 explain.


    Sincerely, Highly skilled coding monkey.


    Sunday, October 14, 2018 8:15 PM