C
C#15mo ago
apparition

❔ Homework Help... Again... Chars and Conditional Statements

Hi, for this problem, I am given a char, starter, and an int, number. I have to find the subsequent characters based on the value of number and return them as a string. For example: starter is g number is 5 return is ghijk I would prefer just help with where to go from what I have right now, and would appreciate it if I am not outright given the answer.
4 Replies
apparition
apparition15mo ago
public static string Test6(char starter, int number)
{
string answer = "";
for(int i = 1; i < number; i++)
{
answer = ((char)(starter + i).ToString()l
}
return answer;
}
public static string Test6(char starter, int number)
{
string answer = "";
for(int i = 1; i < number; i++)
{
answer = ((char)(starter + i).ToString()l
}
return answer;
}
this is what I have right now, and it is only outputting the last char of the string needed EX: if expected is ghijk, my code is returning k
Angius
Angius15mo ago
Because you keep replacing the answer You probably want to append to it With += for example
apparition
apparition15mo ago
god dammit i thought thats what i was supposed to do but i put the += between starter and i instead of answer and Smoge works now, thank you.
Accord
Accord15mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts