Solved

DirectorySeparatorChar

Posted on 2013-05-23
3
183 Views
Last Modified: 2013-05-23
The statement below does not compile because of the DirectorySeparatorChar.
What should be used?
if (identitySection.UserName.IndexOfAny(System.IO.Path.DirectorySeparatorChar) > 0) {

Open in new window

0
Comment
Question by:allelopath
  • 2
3 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 39192182
if (identitySection.UserName.IndexOfAny(new char[] { System.IO.Path.DirectorySeparatorChar }) > 0)
            {
            }

Open in new window


IndexOfAny expect array of char:
http://msdn.microsoft.com/en-us/library/system.string.indexofany.aspx
0
 
LVL 1

Author Comment

by:allelopath
ID: 39192214
Why an array of char? I just need one char.
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 39192263
that's how the function is declared.
you can pass 1 char or many, but in order to support more than a single char, the passing argument must be an array.
so basically u pass an array with only 1 char, that is what the code do.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question