Yari-Serve.de

I don't know where I'm going, but I'm on my way

Browsing Posts in C#

As I’m trying to get more familiar with the Entity Framework and its overwhelming features, I’m still stuck on LINQ sometimes. Reading along Microsoft’s LINQ-Forums, I came across a page of two guys: Joe Albahari and Ben Albahari. They wrote down a “best of” of the most common misunderstandings regarding LINQ and Entity Framework 4. [...]

So, they said: “The Entity Framework will be your friend“. “It’s far more easy than writing the SQL Queries yourself“, they said. I have to admit: It’s far more comfortable – but first you need to get used to it. Getting started: This MSDN-Entry explains how you get started with creating a Database-Model, what the [...]

Today I’ve found an awesome listing of how to mess around with exceptions in C#: http://www.codeproject.com/KB/architecture/exceptionbestpractices.aspx

There is only some slow blogging going on recently… So here’s something to fill the Lazyness-Gaps /// <summary> /// Encrypts the specified Text to SHA1 /// </summary> /// <param name="text">The Text to encrypt</param> /// <returns>The SHA1-Encrypted text</returns> public static string EncryptToSHA1(this string text) { SHA1 sha1 = new SHA1CryptoServiceProvider();  byte[] arrayData = Encoding.ASCII.GetBytes(text); byte[] arrayResult [...]

A comprehensive list of culture codes used for localising and in conjunction with the CultureInfo class. The CultureInfo class specifies a unique name for each culture, based on RFC 4646 (Windows Vista and later). The name is a combination of an ISO 639 two-letter lowercase culture code associated with a language and an ISO 3166 [...]

Let’s get a bit more advanced – we’re now converting a WPF-Image to a byte[]. You can then store this byte[] in an MS-SQL Database, for example. /// <summary> /// Converts the specified Image to a byte[] /// </summary> /// <param name="imageToConvert">The Image you wish to convert</param> /// <returns>A Byte[], containing the images Information</returns> public [...]

Let’s go ahead with a little Code-Snippet regarding the FileSize in C#. Sometimes you need to display a “nice file size” – values like 14865343435 Bytes are absolutely useless for Userfriendly Interfaces… /// <summary> /// Creates a nicer FileSize from bytes /// </summary> /// <param name="size">The Size to Parse</param> /// <returns>The converted FileSize, including the [...]