C
C#3y ago
gododo

❔ Help me out please

Im trying tho encrypt words and im pretty much stuck in here. Im very weak at coding so please forgive me in advance
18 Replies
gododo
gododoOP3y ago
gododo
gododoOP3y ago
im trying to like change the letter inside the array
TheBoxyBear
TheBoxyBear3y ago
What kind of cypher do you want to use?
gododo
gododoOP3y ago
like uh a + 2 = c for example
TheBoxyBear
TheBoxyBear3y ago
foreach is read-only
gododo
gododoOP3y ago
oh so its usless?
TheBoxyBear
TheBoxyBear3y ago
Useful if you don't need to change the values And just do something with each value that doesn't involve putting something else in the source collection
gododo
gododoOP3y ago
can you explain it rq
TheBoxyBear
TheBoxyBear3y ago
foreach relies in IEnumerable which is the backbone of all collection types, including read-only types All foreach knows is it received a character from this unknown collection, then another character and another
gododo
gododoOP3y ago
oh ok
TheBoxyBear
TheBoxyBear3y ago
So use for if you need to replace Then you can use the index array[i] = newValue;
gododo
gododoOP3y ago
ok
gododo
gododoOP3y ago
gododo
gododoOP3y ago
how do i make this work im trying to like replace the letter of the array alf with a letter of the array lett with the help of the key (ch) so again if theres the letter a the array will move ch places and replace it i tried to add the key to the var a but no matter how i convert it, it will always give me an error wait nvm i fixed it for now good job me
friedice
friedice3y ago
Unless I'm missing something, this seems unnecessarily complicated. Can't you just use a dictionary?
gododo
gododoOP3y ago
thats the issue i think i gotta do it without those and also ive never used them anyways
CoffeeZombie
CoffeeZombie3y ago
This is known as a Caesar Shift. I did find some interesting tutorials online. No dictionaries necessary, you can do it with some math and some casting.
Accord
Accord3y 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