Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
Well, I need to subtract the number from a string, and in the end she should continue being a string ...
I try:
PStruct.character[Index, PStruct.player[Index].SelectedChar].Y =
(Convert.ToInt32(PStruct.character[Index, PStruct.player[Index].SelectedChar].Y) - 1)
.ToString;
Character.Y is a string.
The error:
Cannot convert method group "ToString" to non-delegate type "string".
Anyone have tips or a solution?
Use parenthesis to invoke/call a method:
expr.ToString()
Without parenthesis it (ToString) is treated as a "method group", which is useful in some cases - but not here.
As written, you are trying to treat a function ToString as a type string.
As the comment mentioned, you probably meant to write ToString().
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
The testCards string picks up the value from web.config. But every time I try to use int.tryParse it gives a false value when I try to parse the string testCards. Any idea what I might be missing?
<add key ="TestCards" value ="4987654321098769,4111111111111111,4987654321098769"/>
string testCards = ConfigurationManager.AppSettings["TestCards"];
int flag=0
bool isSuceeded=false
isSuceeded = int.TryParse(testCards, out flag);
It's not an int! It has commas in it, and if it didn't have commas the number is much bigger than an int can hold in any .NET platform.
I'm gathering from the name TestCards that these are intended to be credit card numbers? In that case they should be strings.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
When posting data from view, I send it to the Controller via ajax and split the date time value, then the parameter becomes a string and I want to convert it to my datetime, but I encounter such an error
There is a blank/space at the end of your 'date' string. Use bgdate.Trim(). You may also check that bgdate is a non null string and have then a default value with something like (bgdate == null)?"01-01-1970":bgdate.Trim().
There's a white space in your value 08-04-2021 . You should Trim() it:
bgdate.Trim()
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
heres the error Argument 2: cannot convert from 'method group' to 'float'
heres the code
public Transform[] Spawns;
Random.Range(1, Spawns.GetLength);
Array.GetLength is the name of a method, meaning you need to supply a list of arguments enclosed in () to invoke it:
Random.Range(1, Spawns.GetLength(0));
That being said, the more idiomatic solution for assessing the length of a 1-deminsional array in C# would be to just use the Length property:
Random.Range(1, Spawns.Length);
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I have a string path that starts with "file:///" and I am trying to remove it using string.Replace. Here is my code:
//This returns a string that starts with "file:///"
string missionPath = missionDataBase.FileLocationLocal;
missionPath = missionPath.Replace("file///","");
Whenever I check missionPath after the replace, the file:/// is still there - how do you appropriately handle forward slashes when removing them from a string?
You're missing a colon in your search string.
missionPath = missionPath.Replace("file:///","");
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
Trying to use the .NET SubString function. I pass a value to a custom function and then an if statement evaluates if it should be capitalized or not. Then I use the following to change the first letter to upper case. However, it tells me that the "Index was outside the bounds of the array." What am I doing wrong?
char.ToUpper(X[0]) + X.Substring(1)
Wrap it in isNullOrEmpty()
if(!string.IsNullOrEmpty(X))
{
char.ToUpper(X[0]) + X.Substring(1)
}
This might help you out, as it has some sanity checks included
public string FirstLetterToUpper(string str)
{
if (string.IsNullOrEmpty(str))
return str;
return char.ToUpper(str[0]) + str.Substring(1);
}