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);
}
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 4 years ago.
Improve this question
I am trying to check to see if this object contains any letters besides Z and if it does it should return Null. The way I have it initialized gives me no errors but when testing it does not actually return null if a letter is present.
if(request.DoorTag.Contains(#"[a - yA - Y]"))
{
return null;
}
if(Regex.IsMatch(request.DoorTag, "[a-yA-Y]")
{
return null;
}
But "[^zZ]" would even be better, since it'll check that your DoorTag contains any other char than Z
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 5 years ago.
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.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
string input= "hello, how are you today"
i knw the encode is not in proper format thats why i am using a function to replace improper "today" to "today".
f1(input);
but at time of comparing
if (input.Contains("today") == true)
{
lbldisplay.Text = str1;
}
it returing false,i have debugged the program.it is working correctly till replace s1.Replace("a","a");(shown "hello, how are you today") but at return statement return s1; it is returning original value i.e "hello, how are you today".
public string f1(string s1)
{
s1 = s1.Replace("a", "a");
return s1;
}
please help.thank you.
Most likely what is happening is that you're not assigning the return value back to your variable when you call it. The parameter is not declared ref so this will have no effect:
f1(input);
You would need to use this:
input = f1(input);
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
What kind of identifier does the visual studio needs ? i just want to put from outside one int array with 2 different numbers between 0 and 66.
public static void playerLocationChange(int[])
{
}
You have to give the parameter a name. Otherwise, you have no way of referring to it from the function.
public static void playerLocationChange(int[] myIntArrayParam)
//Notice the name next to int[]
//This is the parameter's name
{
}
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().