-
[RESOLVED]implicit conversion from integer to string
Reviewing some code that says
Code:
TextBox14.Text = GetSettingInt("TMaxUPSpeed")
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?
The code is some sample code I am using to be part of a larger app and the code is also from 2009 which shouldnt really make a difference.
Thank you
** Going to Resolve this post, seems to be an open ended debate on the question, I have already sorted the question out, I paid someone to fix the issue instead, I was a tad frustrated by some of the posts, but thanks to all that replied, moving onto other issues.
-
Re: implicit conversion from integer to string
Quote:
Originally Posted by
jokerfool
Reviewing some code that says
Code:
TextBox14.Text = GetSettingInt("TMaxUPSpeed")
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?
The code is some sample code I am using to be part of a larger app and the code is also from 2009 which shouldnt really make a difference.
Thank you
We cant help with the above code as we do not know what GetSettingInt is. None the less its asking for an integer value. Your parsing a string value.
String "The Quick Brown Fox..."
Integer 8 etc..
-
Re: implicit conversion from integer to string
An implicit conversion occurs when you assign a value of one data type to a variable of a different, incompatible data type. For instance, this code implicitly converts a String to an Integer:
Code:
Dim int As Integer = "100"
The value "100" is a String and the 'int' variable can only hold and Integer, so the system has to implicitly convert the String to an Integer and then assign the result to the variable. This code performs an explicitly conversion:
Code:
Dim int As Integer = CInt("100")
CInt explicitly converts the String to an Integer and then assign the result to the variable. In that case the code tells the system exactly what to do rather than assuming that the system will work it out for itself.
In your case, presumably the GetSettingInt method returns an Integer while the Text property of a TextBox (in fact, of any control) is type String. You need to explicitly convert the Integer to a String before assigning it to a String property:
Code:
TextBox14.Text = GetSettingInt("TMaxUPSpeed").ToString()
-
Re: implicit conversion from integer to string
Looking for the GetSettingInt here is the function I think for that
Code:
Function GetSettingInt(ByVal name As String) As Integer
Check()
If FileIO.FileSystem.FileExists(subdirName & "s." & name & ".n") = True Then
Return CInt(File.ReadAllText(subdirName & "s." & name & ".n"))
Else
Return Nothing
End If
End Function
-
Re: implicit conversion from integer to string
Quote:
Originally Posted by
jokerfool
Looking for the GetSettingInt here is the function I think for that
Code:
Function GetSettingInt(ByVal name As String) As Integer
Check()
If FileIO.FileSystem.FileExists(subdirName & "s." & name & ".n") = True Then
Return CInt(File.ReadAllText(subdirName & "s." & name & ".n"))
Else
Return Nothing
End If
End Function
ReadAllText returns a string value. Why are you casting this as an integer?
http://msdn.microsoft.com/en-us/library/ms143368.aspx
vb Code:
Public Class Form1
Function GetSettingInt(ByVal name As String) As String
Dim path As String = String.Format("{0}s.{1}.n", subdirname, name)
If IO.File.Exists(path) Then
Return IO.File.ReadAllText(path)
Else
Return Nothing
End If
End Function
End Class
-
Re: implicit conversion from integer to string
Which one is better and more preferred, implicit or explicit conversion.?
-
Re: implicit conversion from integer to string
Explicit conversions... that's why the general recomendation is to set Option Explicit On by default.
-tg
-
Re: implicit conversion from integer to string
Quote:
Originally Posted by
techgnome
Explicit conversions... that's why the general recomendation is to set Option Explicit On by default.
-tg
You mean Option Strict. Option Explicit has nothing to do with type conversions. Option Explicit determines whether explicit declaration of variables is required while Option Strict determines whether strict typing is enforced. Strict typing means no late binding and no implicit conversions.
-
Re: implicit conversion from integer to string
Quote:
Originally Posted by
ident
ReadAllText returns a string value. Why are you casting this as an integer?
Presumably because the file is a text file but it contains a setting value that represents a number. When you add an Integer to My.Settings it gets stored in the config file. The config file is XML, which is structured text. As such, the value has to be read as text and converted to an Integer at some point. This is no different.
-
Re: implicit conversion from integer to string
The code I am using is from 2008 to 2009 so the code back then may of served its purpose. The code shown is part of the settings, the main app itself works fine and I have no issues with loading etc, I just got a warning on the code for implicit conversion from integer to string. Here is the settings functions, this is where I am getting the warning.
Code:
Imports System.IO
''' <summary>
''' Because My.Setting namespace loose it's data after renaming the assembly file, or moving it, i made this.
''' </summary>
''' <remarks></remarks>
'''
Public Module SettingsManager
' Dim subdirName As String = "opt\"
Dim subdirName As String = MYDIR & "\opt\"
'Sub Check()
' If FileIO.FileSystem.DirectoryExists("opt") = False Then
' FileIO.FileSystem.CreateDirectory("opt")
' End If
'End Sub
Sub Check()
If FileIO.FileSystem.DirectoryExists(subdirName) = False Then
FileIO.FileSystem.CreateDirectory(subdirName)
End If
End Sub
Function GetSettingInt(ByVal name As String) As Integer
Check()
If FileIO.FileSystem.FileExists(subdirName & "s." & name & ".n") = True Then
Return CInt(File.ReadAllText(subdirName & "s." & name & ".n"))
Else
Return Nothing
End If
End Function
Function GetSettingStr(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
''' <summary>
''' Return an empty list if invalid name supplied.
''' </summary>
''' <param name="name"></param>
''' <returns></returns>
''' <remarks></remarks>
Function GetSettingStrList(ByVal name As String) As List(Of String)
Check()
If FileIO.FileSystem.FileExists(subdirName & "s." & name & ".n") = True Then
Return File.ReadAllLines(subdirName & "s." & name & ".n").ToList()
Else
Return New List(Of String)(0)
End If
End Function
Function GetSettingBool(ByVal name As String) As Boolean
Check()
If FileIO.FileSystem.FileExists(subdirName & "s." & name & ".n") = True Then
If File.ReadAllText(subdirName & "s." & name & ".n") = "True" Then
Return True
Else
Return False
End If
Else
Return Nothing
End If
End Function
Sub SetSettingInt(ByVal name As String, ByVal data As Integer)
Check()
File.WriteAllText(subdirName & "s." & name & ".n", data)
End Sub
Sub SetSettingStr(ByVal name As String, ByVal str As String)
Check()
File.WriteAllText(subdirName & "s." & name & ".n", str)
End Sub
Sub SetSettingStrList(ByVal name As String, ByVal list As List(Of String))
Check()
File.WriteAllLines(subdirName & "s." & name & ".n", list.ToArray)
End Sub
Sub SetSettingBool(ByVal name As String, ByVal bool As Boolean)
Check()
File.WriteAllText(subdirName & "s." & name & ".n", bool.ToString)
End Sub
Sub SetSettingFont(ByVal name As String, ByVal font As Font)
Check()
'Dim d As New Font("font family", Size, FontStyle.Regular, GraphicsUnit.Pixel, font.GdiCharSet)
Try
Dim fontfamilyStr As String = font.FontFamily.Name
Dim sizeStr As String = font.Size
Dim styleStr As String = font.Style.ToString
Dim gdiChatSet As String = CInt(font.GdiCharSet)
Dim text As String = fontfamilyStr & "|" & sizeStr & "|" & styleStr & "|" & gdiChatSet
File.WriteAllText(subdirName & "s." & name & ".n", text)
Catch ex As Exception
End Try
End Sub
Function getSettingFont(ByVal name As String) As Font
Check()
If FileIO.FileSystem.FileExists(subdirName & "s." & name & ".n") = True Then
Dim t As String() = File.ReadAllText(subdirName & "s." & name & ".n").Split(CChar("|"))
Dim fontfamilyStr As String = t.ElementAt(0)
Dim sizeStr As Single = CSng(t.ElementAt(1))
Dim styleStr As FontStyle = getFontStyle(t.ElementAt(2))
Dim gdiChatSet As Byte = CByte(t.ElementAt(3))
Return New Font(fontfamilyStr, sizeStr, styleStr, GraphicsUnit.Point, gdiChatSet)
Else
Return Nothing
End If
End Function
Private Function getFontStyle(ByVal s As String) As FontStyle
Select Case s
Case "Bold"
Return FontStyle.Bold
Case "Italic"
Return FontStyle.Italic
Case "Regular"
Return FontStyle.Regular
Case "Strikeout"
Return FontStyle.Strikeout
Case "Underline"
Return FontStyle.Underline
Case Else
Return FontStyle.Regular
End Select
End Function
End Module
-
Re: implicit conversion from integer to string
You're getting the warning since GetSettingInt returns an integer and you're assigning that to the Text property of a TextBox which is a String property. If you want to get rid of the warning use either of these two code lines:
Code:
TextBox14.Text = GetSettingInt("TMaxUPSpeed").ToString()
'or
TextBox14.Text = CStr(GetSettingInt("TMaxUPSpeed"))
It's always better to explicitly convert data types because you are in that case in control and the compiler doesn't have to make assumptions of what you're really trying to do. I would recommend to turn Option Strict on.
-
Re: implicit conversion from integer to string
File.ReadAllText() returns a string though, so I'm assuming that the text you want to read is supposed to be cast to an integer. I might suggest Integer.TryParse() in that case, and return either a null string, or string.Empty on false. (Check that accordingly, and do whatever you need to do based on the returned value.) Or make this function take on the paradigm of the TryParse() method using a ByRef param, and returning a boolean based on TryParse() success or failure...
Since the value is being used for text though, why cast to an integer in the first place only to convert back to a string? Seems inefficient, and especially if you aren't going to be using this Integer value for anything else. If you want validation Integer.TryParse() is the way to go...
As mentioned above, unless you've changed your settings, Option Explicit is already on by default anyways, but Option Strict is the one that you want to have turned on. Implicit conversions are bad, and they also don't teach you to recognize what types you are dealing with if you always rely in implicit conversions being done for you. I once read an article that had this as a defense somehow for why VB.net is better than C#... Not sure how that works, but that's another story. :)
Cheers
-
Re: implicit conversion from integer to string
Quote:
Originally Posted by
Joacim Andersson
You're getting the warning since GetSettingInt returns an integer and you're assigning that to the Text property of a TextBox which is a String property. If you want to get rid of the warning use either of these two code lines:
Code:
TextBox14.Text = GetSettingInt("TMaxUPSpeed").ToString()
'or
TextBox14.Text = CStr(GetSettingInt("TMaxUPSpeed"))
It's always better to explicitly convert data types because you are in that case in control and the compiler doesn't have to make assumptions of what you're really trying to do. I would recommend to turn Option Strict on.
Which is exactly what I said in post #3, so one wonders why the OP is still asking the same question and hasn't acted on the advice provided there.
-
Re: implicit conversion from integer to string
Quote:
Originally Posted by
AceInfinity
Since the value is being used for text though, why cast to an integer in the first place only to convert back to a string? Seems inefficient, and especially if you aren't going to be using this Integer value for anything else.
You seem to be missing the point that I made in post #9. It's clear from the method name that this data represents part of the application's preferences/options/settings. The data obviously represents a number so it is completely appropriate that it be returned as a number. When the data gets used it will be used as a number. This is presumably not the only place that this setting value will be used. This particular instance is for display purposes so, as with all data, it must be in String form for that purpose. Elsewhere though, it is likely that the data will be used in a comparison with another number, so it is essential that it be a number. Would you say that My.Settings should return everything as Strings? If not then why should these home-grown settings be returned as Strings?
The possibility that the file doesn't contain a valid number has to be taken into account somewhere. If your suggestion to use TryParse is not taken up then any code that calls this method really should have it within an exception handler.
-
Re: implicit conversion from integer to string
Quote:
Originally Posted by
jmcilhinney
You seem to be missing the point that I made in post #9. It's clear from the method name that this data represents part of the application's preferences/options/settings. The data obviously represents a number so it is completely appropriate that it be returned as a number. When the data gets used it will be used as a number. This is presumably not the only place that this setting value will be used. This particular instance is for display purposes so, as with all data, it must be in String form for that purpose. Elsewhere though, it is likely that the data will be used in a comparison with another number, so it is essential that it be a number. Would you say that My.Settings should return everything as Strings? If not then why should these home-grown settings be returned as Strings?
The possibility that the file doesn't contain a valid number has to be taken into account somewhere. If your suggestion to use TryParse is not taken up then any code that calls this method really should have it within an exception handler.
Quote:
Originally Posted by
jmcilhinney
Presumably because the file is a text file but it contains a setting value that represents a number. When you add an Integer to My.Settings it gets stored in the config file. The config file is XML, which is structured text. As such, the value has to be read as text and converted to an Integer at some point. This is no different.
You are probably right. And if he uses this value lots of times as an Integer, I suppose a simple redundant cast back to a string wouldn't matter too much. He wouldn't have to cast the value to an Integer a whole bunch of times though when he wants to use it if the return value stays as is. I didn't consider the bigger picture and was only looking at the smaller inefficiency here, because I have a habit of only reading the thread and judging based on the given information.
Regards,
Ace
-
Re: implicit conversion from integer to string
why is everyone talking about conversions, the question was what does the line of code do
Quote:
TextBox14.Text = GetSettingInt("TMaxUPSpeed")
and
Quote:
Function GetSettingInt(ByVal name As String) As Integer
Check()
If FileIO.FileSystem.FileExists(subdirName & "s." & name & ".n") = True Then
Return CInt(File.ReadAllText(subdirName & "s." & name & ".n"))
Else
Return Nothing
End If
End Function
simply checks if a file named "TMaxUpSpeed" exists
if it does it puts the contents of the file ( an intergeter probably) in a textbox, its wrongly coded and conversions dont need to be applied
if it does not then the textbox is left empty
it seems a little pointless(with the way its done) but thats what its doing
its that simple.
why are all u guys confusing jokerfool by following up with the conversions stuff?
-
Re: implicit conversion from integer to string
Quote:
Function GetSettingInt(ByVal name As String) As Integer
Check()
If FileIO.FileSystem.FileExists(subdirName & "s." & name & ".n") = True Then
Return CInt(File.ReadAllText(subdirName & "s." & name & ".n"))
Else
Return Nothing
End If
End Function
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
-
Re: implicit conversion from integer to string
Why? If the text in the file is an integer why shouldn't the function return an integer? It would be safer to use Integer.TryParse than CInt but the function is still returning an integer, and (unless the function causes an exception) the textbox will never be empty since the function is always returning an integer. Nothing for an integer is equal to 0.
The warning is because the integer that is returned is added to a textbox and should first be converted as posted earlier.
-
Re: implicit conversion from integer to string
So I just want to clarify that the code I am using is from 2008, please understand this, I didn't write the code, I am just asking for assistance. So thank you to the posts, I will take everything on board and make the changes. Thank you.
-
Re: implicit conversion from integer to string
Quote:
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.
Quote:
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
-
Re: implicit conversion from integer to string
OMG Integer or String, its all too much for me now, im so confused and it doesnt matter who explains it except for post #2, I think I understand.
This post was never intended to be a debate, I had the warning when I go to build, it didnt stop the function of the app, I just wanted to know how to remove the warning, it seems I will have to edit the code in the settings file as explained above and in doing so it has removed the error from certain lines and now refers to other lines in the settings file e.g. SetSettingInt, but there are hundreds of lines related to that error, would this mean going in and changing all those lines from int to str? I am sorry if I am not the expert here I am only the beginner and trying to learn as much as I can before the end of the line arrives for me, but thank you too all.
-
Re: implicit conversion from integer to string
Why is it too much? What are you confused about? Let us know and we can help. :)
Post #3, is where the implicit conversion phenomena is best explained in my opinion: http://www.vbforums.com/showthread.p...=1#post4417245
The return value from the function is an Integer, the Text property when set, expects a type of string, so when you assign that Integer to the placeholder of the Text property, a magical conversion is done for you (an implicit conversion from the original Integer, to the String value). To avoid the "magician" doing this magic for you so to speak, you need to cast that Integer value to a string first before you assign it to the Text property. That's how you would fix it.
So as mentioned above, either CStr(), or the ToString() extension method.
Quote:
it seems I will have to edit the code in the settings file as explained above
No, that function is fine... The only modification you might consider making to it, is adding Integer.TryParse() in there instead of CInt(). Everything else is fine, you shouldn't need to do anything with the function...
-
Re: implicit conversion from integer to string
Ahhhh lightbulb to head
The textbox with the error is a text box that requires the user to enter a number
Which I believe is the Integer.
What is the meaning of implicit conversion, I dont get.
So it wants to change from a number to a letter is that what this error is referring too?
-
Re: implicit conversion from integer to string
AceInfinity I was referring too
String "The Quick Brown Fox..."
Integer 8 etc..
-
Re: implicit conversion from integer to string
Quote:
So it wants to change from a number to a letter is that what this error is referring too?
By "letter", the proper term is String, but yes. :)
The Text property is a type of String. Thus it doesn't accept an Integer. Some kind of conversion needs to happen to get the value to a type of String, before the Text property can hold that value. So if you don't have Option Strict On, and you don't do this conversion yourself (explicitly), an implicit conversion happens and this conversion is dealt with for you automatically (when a conversion can be made). This is bad practice though and should be avoided, so that's why you are getting the notification about it.
-
Re: implicit conversion from integer to string
When I change to .ToString() it says:
Expression does not produce a value
Hence why I didnt change anything further
Should I turn on Option Strict On and if so how?
-
Re: implicit conversion from integer to string
Quote:
Originally Posted by
jokerfool
When I change to .ToString() it says:
Expression does not produce a value
Hence why I didnt change anything further
Did you do:
Code:
TextBox14.Text = GetSettingInt("TMaxUPSpeed").ToString()
???
And to imagine this implicit conversion stuff. Lets say that the GetSettingInt() function returns a value of 9 in this case.
If you write this in your code:
You will get the same warning. But the implicit conversion takes that 9 and makes it "9" (a string). This would fix that warning:
Code:
TextBox14.Text = "9"
Or in this case 9 is a placeholder for our function (we can't just put quotes around the function, otherwise it makes the function name our string, and not its return value), so the ToString() function is used:
Code:
TextBox14.Text = (9).ToString()
-
Re: implicit conversion from integer to string
I did add the .tostring but I got that error above. Instead I added this code as mentioned and the error went away
Code:
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
-
Re: implicit conversion from integer to string
Hi,
ok yes i read it again, i missed your post.
and since it looks like its getting some sort of setting that's numerical then it makes sense to have the function like that.
i wasnt thinking but practically its a good way to get "0" in the string if there is nothing there, since naturally integers start of as 0.
point taken :) sry
the function still is has potential problems with the way it is, and is relying of outside information being correct to prevent a crash.
-
Re: implicit conversion from integer to string
jokerfool please NOTE
if the function is used somewhere else while code like my suggestion, you will need to do more conversions, but if its not then you will be fine.
the error you have might also be caused by the file itself, you should check the data inside the file.
obviously you cant use Cint("with this") because there are no numbers there, i dont know what it would return but it wouldnt be what you wanted that is sure.
-
Re: implicit conversion from integer to string
Quote:
Originally Posted by
jokerfool
I did add the .tostring but I got that error above. Instead I added this code as mentioned and the error went away
Code:
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
No... Please read through the posts again, it was suggested not to do this as a final consensus.
Does this make sense?
1. GetSettingInt
2. Return value: String
What was the error you were getting with ToString()?
-
Re: implicit conversion from integer to string
When I change to .ToString() it says:
Expression does not produce a value
-
Re: implicit conversion from integer to string
I have a hard time believing that you're using the function correctly.. Can you show us your exact code when it gives you that error and are you sure it is with that line?
-
Re: implicit conversion from integer to string
Already did that, its posted above.
-
Re: implicit conversion from integer to string
Quote:
Originally Posted by
jokerfool
When I change to .ToString() it says:
Expression does not produce a value
Then you did it wrong. How about you show us what you did and then we can tell you what's wrong with it?
-
Re: implicit conversion from integer to string
Okay I guess I must of made a mistake somewhere, so is this correct? Cos the line is no longer highlighted saying that message, but will adding that .ToString() to the end of the line chance the functionality of the application?
TextBox14.Text = GetSettingInt("TMaxUPSpeed").ToString()
-
Re: implicit conversion from integer to string
you should double check the file that you getting the info for, your applying a text extraction, maybe the file contains an object, or nothing at all.
you said you already changed the function to return string, what did the textbox show when you did that?
-
Re: implicit conversion from integer to string
When I made that change you mentioned the error for that section disappeared, the error moved onto another section within the settings that I mentioned above
-
Re: implicit conversion from integer to string
Quote:
Originally Posted by
jokerfool
Okay I guess I must of made a mistake somewhere, so is this correct? Cos the line is no longer highlighted saying that message, but will adding that .ToString() to the end of the line chance the functionality of the application?
TextBox14.Text = GetSettingInt("TMaxUPSpeed").ToString()
No it won't. Either way, the number is being retrieved from the file and displayed in the TextBox. The difference is that the ToString means that the Integer is converted to a String explicitly while previously it was being converted implicitly. It's being converted either way though. Do you actually know what implicit and explicit mean? That would probably be a good place to start.
-
Re: implicit conversion from integer to string
-
Re: implicit conversion from integer to string
Quote:
Originally Posted by
jokerfool
I didn't actually ask whether you knew what implicit and explicit conversions are. I asked whether you knew what the words "implicit" and "explicit" mean. They are not specifically programming terms and, as apparently a native English speaker, you should know what they mean already. If you know how to imply something, i.e. suggest something without actually saying it outright, then you know what implicit means. If you know what implicit means then you inherently know what explicit means. If you do something and I say that only a stupid person would do that, I'm obviously saying that you're stupid but I never actually said that you're stupid. The fact that you're stupid is implicit in my statement. If I just came out and called you stupid then my statement would be explicit. By the way, I don't actually think you're stupid. That was just an example that came to mind. ;)
Now, in your code, you are assigning an Integer value to a String property. A String property can only hold a String so you are implying that the value must be converted without actually converting it. That's an implicit conversion. If you convert the value yourself then that's an explicit conversion.
-
Re: implicit conversion from integer to string
I completely agree it's no different. How ever i was more encouraging the op to show me evidence he was using an integer as a setting rather then have us guess. Then we could of suggest a more valid handling using integer.parse etc.
-
Re: implicit conversion from integer to string
The OP has obviously inherited the code so he might not know where and how this function is used elsewhere. By just looking at the naming convention used by this method one must assume that it was intended for this function to return an integer and most likely for good reasons.
-
Re: implicit conversion from integer to string
Quote:
Originally Posted by
Joacim Andersson
The OP has obviously inherited the code so he might not know where and how this function is used elsewhere. By just looking at the naming convention used by this method one must assume that it was intended for this function to return an integer and most likely for good reasons.
For such a basic question should we just assume the OP knows any thing about naming conventions? I simply decided not to assume the op understand whats being returned since his/hers question referenced implicit conversion.
-
Re: implicit conversion from integer to string
But the code is inherited, the OP did not write the project or this method. Why do you assume that the intended code should look different? The question that was asked was answered already in post #3 (or was it #4). I don't understand why this pretty simple and straight forward question has caused this thread to become 45 posts in length.