|
-
May 19th, 2013, 12:31 AM
#14
Re: implicit conversion from integer to string
 Originally Posted by GBeats
should be
Function GetSettingInt(ByVal name As String) As string
Check()
If FileIO.FileSystem.FileExists(subdirName & "s." & name & ".n") = True Then
Return File.ReadAllText(subdirName & "s." & name & ".n")
Else
Return Nothing
End If
End Function
If the return value was a string, then GetSettingInt wouldn't make sense would it? And this was part of the discussion if you look through the thread. 
The setting is intended to be an Integer from the very beginning, so why should it be a string? You're going to be using it perhaps more as an Integer than a String, so for this one place where you would use it as a string, why would you make the function fit this type? Then all the other places where you use it as an Integer, you have to manually cast it each time, instead of returning that value directly from the function.
And no... He was asking what the implicit conversion bit meant on that line, not what the code itself does.
Being new to programming, can someone explain to me in the most basic format what exactly this means, what does implicit conversion mean and implicit conversion from integer to string mean, what is it trying to tell me here?
When he said "can someone explain to me in the most basic format what exactly this means," he was referencing the implicit conversion notice. 
My suggestion was Integer.TryParse(), so if you didn't have the return value as an Integer, then imagine implementing TryParse() everywhere you use this string, just to have a usable integer representation of the text in the file? Rethinking this over, it makes much more sense to stay an Integer.
~Ace
Last edited by AceInfinity; May 19th, 2013 at 12:36 AM.
<<<------------
.NET Programming (2012 - 2018)
®Crestron - DMC-T Certified Programmer | Software Developer <<<------------
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|