C
C#2y ago
Reki-

❔ ✅ Convert and put , after 3 number

21 Replies
Reki-
Reki-OP2y ago
Reki-
Reki-OP2y 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
Angius2y 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-OP2y ago
let me do it thank you string[] data = str.Split(' '); it is correct or not?
Angius
Angius2y ago
This will split the string by space So
MODiX
MODiX2y 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-OP2y ago
so if there the value with no space this code didn't split right?
MODiX
MODiX2y 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
Angius2y ago
Correct
Reki-
Reki-OP2y ago
ahhh how about i want to like 12 but one value store in array like arr[0] : 1 arr[1] : 2
Pobiega
Pobiega2y ago
A string is already a char array.
MODiX
MODiX2y 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-OP2y ago
ohhh i seee
MODiX
MODiX2y 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
Angius2y ago
Ah, ninja'd
Reki-
Reki-OP2y ago
can you write the code for me i still can't do it man i'm so dumb man
MODiX
MODiX2y 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
Angius2y ago
Something like that
Reki-
Reki-OP2y ago
thank you so much i'll try it thank you for helping me i already finish my homework !solve
Pobiega
Pobiega2y ago
/close
Accord
Accord2y 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