C
C#15mo ago
FSHF

clone

Instead of removing last number i would like to clone, how?
private void btnpocl(object sender, EventArgs e)
{

if (ccal.Length > 0)
{
ccal = ccal.Remove(ccal.Length - 1, 1);
}

txtbout.Text = ccal;
}
private void btnpocl(object sender, EventArgs e)
{

if (ccal.Length > 0)
{
ccal = ccal.Remove(ccal.Length - 1, 1);
}

txtbout.Text = ccal;
}
44 Replies
JakenVeina
JakenVeina15mo ago
huh?
FSHF
FSHF15mo ago
this function remove last symbol in my string, instead i would like to clone it / copy the last symbol of string. How can i do that?
JakenVeina
JakenVeina15mo ago
what do you mean "clone it/copy it?
FSHF
FSHF15mo ago
i want to use the last symbol again for ekvation f.e lastnumber - 5
JakenVeina
JakenVeina15mo ago
so
Pobiega
Pobiega15mo ago
ccal is a string here, right?
JakenVeina
JakenVeina15mo ago
var lastCharacter = ccal[^0];
var lastCharacter = ccal[^0];
?
FSHF
FSHF15mo ago
yes
Pobiega
Pobiega15mo ago
var last = ccal[^1]; ^1 is correct
JakenVeina
JakenVeina15mo ago
is it ^1 or ^0? k
Pobiega
Pobiega15mo ago
^0 is oob
JakenVeina
JakenVeina15mo ago
I've had virtually 0 opportunity to use that syntax since it was added
MODiX
MODiX15mo ago
Pobiega#2671
REPL Result: Success
"12345"[^1]
"12345"[^1]
Result: char
5
5
Compile: 461.186ms | Execution: 38.873ms | React with ❌ to remove this embed.
JakenVeina
JakenVeina15mo ago
"clone" and "copy" are very much not the words to use for this
FSHF
FSHF15mo ago
im getting red under ^1
Pobiega
Pobiega15mo ago
are you using an old .NET version?
FSHF
FSHF15mo ago
the latest nvm
Pobiega
Pobiega15mo ago
You could still have picked .net framework during project creation, even if you made it a day ago.
FSHF
FSHF15mo ago
whats the latest?
Pobiega
Pobiega15mo ago
.NET 7
FSHF
FSHF15mo ago
how do i check
Pobiega
Pobiega15mo ago
open your .csproj file
FSHF
FSHF15mo ago
CS8370 Feature 'index operator' is not available in C# 7.3. Please use language version 8.0 or greater. C
Pobiega
Pobiega15mo ago
Yeah you are 100% using .net framework.
FSHF
FSHF15mo ago
thats the error code i got, cant find my .csproj
Pobiega
Pobiega15mo ago
are you using visual studio 2022?
FSHF
FSHF15mo ago
yes
Pobiega
Pobiega15mo ago
$newproject
MODiX
MODiX15mo ago
When creating a new project, prefer using .NET over .NET Framework, unless you have a very specific reason to be using .NET Framework. .NET Framework is now legacy code and only get security fix updates, it no longer gets new features and is not recommended. https://cdn.discordapp.com/attachments/569261465463160900/899381236617855016/unknown.png
Pobiega
Pobiega15mo ago
you picked one of the "NO" options
FSHF
FSHF15mo ago
is there a solution to it
Pobiega
Pobiega15mo ago
Create a new project and copy your stuff over most of it will likely work with little changes, since its a new project and you are still a beginner
FSHF
FSHF15mo ago
will try
FSHF
FSHF15mo ago
Does it matter which i choose
Pobiega
Pobiega15mo ago
6 .net 6
FSHF
FSHF15mo ago
can i just copy and paste over the folder and files for it to work?
Pobiega
Pobiega15mo ago
no only the .cs files
FSHF
FSHF15mo ago
ok
var lccal = ccal[^1];
double ans = Math.Pow(lccal, 2);
ccal += ans.ToString();
var lccal = ccal[^1];
double ans = Math.Pow(lccal, 2);
ccal += ans.ToString();
would this be right for doing power of 2 on the last number
Pobiega
Pobiega15mo ago
no because llcal will be a char
FSHF
FSHF15mo ago
is there a way to remove first instead of last?
TheRanger
TheRanger15mo ago
remove or copy?
FSHF
FSHF15mo ago
i got ^2 working but i need to remove when i 5^2 i get 525 because i havent removed 5
TheRanger
TheRanger15mo ago
? can u elaborate
FSHF
FSHF15mo ago
nvm got it working, thx
Want results from more Discord servers?
Add your server
More Posts
whats the symbol for power of?symbol or what i gotta do to get it❔ Why could NuGet restore randomly timeout inside GitHub Actions?So frequently `nuget restore` timeout inside GitHub Actions for months and I can't figure out what c❔ How would I implement a toroidal universe?A while ago I had started a project to hopefully create John Conway's Game of Life. I have everythin❔ How would I have a compiled Class Library look for necessary reference in a folder other than ./I am creating a game mod via Melon Loader, and I want to have the compiled .dll look for its referen❔ asp.net MVC, can I store some data in a static variable to access in a future request??I might need to modify a current process where user uploads a shit ton of data via excel. the server❔ journal system?https://www.youtube.com/watch?v=OWvicJkXv94 is there an easier way of implementing a journal system ❔ Bug in blazor?Hello guys, i have encountered something strange in my blazor app. I'll try to explain it here. So i❔ Unescaping special charactersWorking on a little SaaS thumbnail preview tool I'm gonna sell, and special characters like apostrop❔ How could I make it so that every tabpage on a tabcontrol fades in when you open them?How could I make it so that every tabpage on a tabcontrol fades in when you open them?❔ How to take a native crash [{0x7f803bba7228} + 0x3bd] + PDB/DLL and get a line number?I have a native crash from a .net application on macOS that contains some managed code in the stack.