C
C#15mo ago
Reki-

❔ ✅ Convert and put , after 3 number

21 Replies
Reki-
Reki-15mo ago
Reki-
Reki-15mo ago
look like this 101999 ------> 101,999 if 134343342 --->>134,343,342 please help me i don't know how to put ' , 'this in the right number is khmer number so don't worry just want to know how to put , in only " , " this one please help me thank you ....!
Angius
Angius15mo ago
You'd could assemble the string in a loop, not with string.Join(). And, after every 3rd character, insert an additional comma. You'd need to do that in reverse, too Since it's 10,000,000 and not 100,000,00
Reki-
Reki-15mo ago
let me do it thank you string[] data = str.Split(' '); it is correct or not?
Angius
Angius15mo ago
This will split the string by space So
MODiX
MODiX15mo ago
Angius#1586
REPL Result: Success
"1 2 3456".Split(' ')
"1 2 3456".Split(' ')
Result: string[]
[
"1",
"2",
"3456"
]
[
"1",
"2",
"3456"
]
Compile: 457.259ms | Execution: 27.155ms | React with ❌ to remove this embed.
Reki-
Reki-15mo ago
so if there the value with no space this code didn't split right?
MODiX
MODiX15mo ago
Angius#1586
REPL Result: Success
"123456".Split(' ')
"123456".Split(' ')
Result: string[]
[
"123456"
]
[
"123456"
]
Compile: 485.236ms | Execution: 29.440ms | React with ❌ to remove this embed.
Angius
Angius15mo ago
Correct
Reki-
Reki-15mo ago
ahhh how about i want to like 12 but one value store in array like arr[0] : 1 arr[1] : 2
Pobiega
Pobiega15mo ago
A string is already a char array.
MODiX
MODiX15mo ago
Pobiega#2671
REPL Result: Success
"hello"[1]
"hello"[1]
Result: char
e
e
Compile: 377.976ms | Execution: 28.528ms | React with ❌ to remove this embed.
Reki-
Reki-15mo ago
ohhh i seee
MODiX
MODiX15mo ago
Angius#1586
REPL Result: Success
foreach (char ch in "12345")
{
Console.WriteLine($"Letter {ch}");
}
foreach (char ch in "12345")
{
Console.WriteLine($"Letter {ch}");
}
Console Output
Letter 1
Letter 2
Letter 3
Letter 4
Letter 5
Letter 1
Letter 2
Letter 3
Letter 4
Letter 5
Compile: 671.383ms | Execution: 91.253ms | React with ❌ to remove this embed.
Angius
Angius15mo ago
Ah, ninja'd
Reki-
Reki-15mo ago
can you write the code for me i still can't do it man i'm so dumb man
MODiX
MODiX15mo ago
Angius#1586
REPL Result: Success
var result = "";
var src = "hello world!";
for (var i = 0; i < src.Length; i++)
{
if (i % 2 == 0) result += "!";
result += src[i];
}
result
var result = "";
var src = "hello world!";
for (var i = 0; i < src.Length; i++)
{
if (i % 2 == 0) result += "!";
result += src[i];
}
result
Result: string
!he!ll!o !wo!rl!d!
!he!ll!o !wo!rl!d!
Compile: 569.500ms | Execution: 78.416ms | React with ❌ to remove this embed.
Angius
Angius15mo ago
Something like that
Reki-
Reki-15mo ago
thank you so much i'll try it thank you for helping me i already finish my homework !solve
Pobiega
Pobiega15mo ago
/close
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.