Skip to main content

Posts

Showing posts from August, 2010

Named Parameter feature of C#.Net 4.0

Lets assume, your constructor definition looks like this: public Employee( string firstName, string lastName, DateTime dateOfBirth) In that case, you have no other option in C# 3.0 other than to invoke the constructor like this: Employee employee = new Employee ( "Shweta" , "Jain" , new DateTime(1990, 1, 1)); So, now in this case, it is not clear about what is being assigned in the constructor (e.g., that third DateTime parameter might be date of birth, might be date hired, who knows).   In C# 4.0, you can invoke the constructor like this: Employee employee = new Employee(firstName: "Shweta " , lastName: "Jain" , dateOfBirth: new DateTime(1990, 1, 1)); This expresses the intent clearly and makes the code more understandable. 

Certificate Signing

Signing a message, means authentifying that you have yourself assured the authenticity of the message (most of the time it means you are the author, but not neccesarily). The message can be a text message, or someone else's certificate. To sign a message, you create its hash, and then encrypt the hash with your private key, you then add the encrypted hash and your signed certificate with the message. The recipient will recreate the message hash, decrypts the encrypted hash using your well known public key stored in your signed certificate, check that both hash are equals and finally check the certificate.