Convert.ToInt32();

Apr 9, 2012 at 8:29 AM

Hello this morning I had a big problem with the convertion from string to int
Here is my code:

else

if (com == "rfichier")

{ 

for (int i = 0; i < Filesystem.Vfs.HardDrive.Drive.GetDisk("C").GetFiles(); i++)

{

 

string data = Filesystem.Vfs.HardDrive.Drive.GetDisk("C").files[i].data;

 

Console.Write("L'id du fichier : " );

 

var rf = Console .ReadLine();

Console.WriteLine(Filesystem.Vfs.HardDrive.Drive.GetDisk(

"C").files[Convert.ToInt32(rf)].data);

 

}

}


Hello this morning I had a big problem with the convertion from string to int
Here is my code:

Coordinator
Apr 9, 2012 at 8:32 AM
What's the issue?

On Mon, Apr 9, 2012 at 10:30 AM, monster12 <notifications@codeplex.com> wrote:

From: monster12

Hello this morning I had a big problem with the convertion from string to int
Here is my code:

else

if (com == "rfichier")

{

for (int i = 0; i < Filesystem.Vfs.HardDrive.Drive.GetDisk("C").GetFiles(); i++)

{

string data = Filesystem.Vfs.HardDrive.Drive.GetDisk("C").files[i].data;

Console.Write("L'id du fichier : " );

var rf = Console .ReadLine();

Console.WriteLine(Filesystem.Vfs.HardDrive.Drive.GetDisk(

"C").files[Convert.ToInt32(rf)].data);

}

}


Hello this morning I had a big problem with the convertion from string to int
Here is my code:

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Developer
Apr 9, 2012 at 1:19 PM

Firstly, learn to use the right methods for the right things, you should be using int.Parse, not Convert.ToInt32() (this is mostly for speed reasons, because you know the type of input you'll be getting, so you don't need to be trying to convert it to an int through a large number of other possible types of input). The Convert class requires an entirely seperate set of plugs for it to work.

Developer
Apr 17, 2012 at 5:57 PM

I don't think int.parse is working at the moment and I remember having a problem with it so unfortunatly I was forced to use (int)uint.parse to get the same result

Apr 17, 2012 at 6:41 PM
melikesPCcheese wrote:

I don't think int.parse is working at the moment and I remember having a problem with it so unfortunatly I was forced to use (int)uint.parse to get the same result

I know int32.parse() works, but uint32.parse doesnt I dont think. But if you want it to a uint just do (uint)int32.parse() - Matt