I'm sitting in C# for about 2 days and it's already like lifting 300KG block.
I don't get it, if I Googled how to get SHA512 hash of string in C#, I get many wonderful
variations on how-to. But when I copy paste this:
public static string GetCrypt(string text)
{
string hash = "";
SHA512 alg = SHA512.Create();
byte[] result = alg.ComputeHash(Encoding.UTF8.GetBytes(text));
hash = Encoding.UTF8.GetString(result);
return hash;
}
It says that "SHA512" doesn't exist in this context. I don't understand it. I haven't done anything wrong, I just copy pasted it into fresh project and pasted it here.
Now, problem may be that return
would work with consoles. But even then when I want to find snippet e.g. "how to get MAC address C# WPF". They give me great code which should message-box me, but nope! Instead everything is either marked green or red, and when I look at error checker.
AND I'M SO TIRED. I thought it would be like PHP or JavaScript. You copy paste snippet, modify where required, play with it, delete it, write your own, learnt. But with C#, you're already taken down on 1st step.
Does anybody have any hints for me, on how should I switch my way of thinking? Program can't be wrong, it's me not having enough knowledge to use it properly. So once again, does anybody have idea on how to think while using Visual Studio 2013 while programming C# for someone who knows only PHP, JavaScript and DOS?
Sorry for spamming you guys, I know you have better things to do, then sit on your chairs and facepalming all the way. But I don't know what's holding me back, so far I know many snippets are already considered an error for "not's sake". Help, please :).
Is there something more I should take in consideration? One-liners "Laws of Reconsider and Remember" in C#?