Category Results  

Implicit Operator

Implicit operator provides developer to cast a type to another type implicitly. Let’s assume i have an object of Car class and want to cast it to MyCar class implicitly. Take a look at he following example to see how it works

Read More
General

Explicit Operator

Explicit operator provides developer to cast a type to another type explicitly. Let’s assume i have an object of Car class and want to cast it to MyCar class explicitly. Take a look at he following example to see how it works

Read More
General

Extension Method

Extension method allows developers to extend functionalities of existing classes. Static classes keep extension methods as being static methods. Developers can add new functionalities for exisiting classes by implementing extension methods for them. Let’s look at the following examples to see how extension methods work.   For example, i need a function that compares two […]

Read More
General

Comparing Objects

Here are a few examples about how to compare two objects by their properties. Equals method is not appropriate for comparing two objects with their properties unless it is overriden. Because Equals method compares objects by their hashcode and their type. So comparing object with their properties is another subject. Let’s continue with the following […]

Read More
General

Deserialize json to object

Here is an example about how to deserialize a json string to an object by help of Newtonsoft.Json. JsonConvert.DeserializeObject(jsonString) deserializes json string to your model easily as it seems.

Read More
General

Serialize object to json

Here is an example about how to serialize an object to json string by help of Newtonsoft.Json. JsonConvert.SerializeObject(yourObject) serializes to json string easily as it seems.

Read More
General

Random text generator

Here is an example about generating random text by given size (4). ASCII codes of small letters are 97 to 122 and ASCII codes of capital letters are 65 to 90. random.Next(x,y) generates a random number x to y-1. We reach the random letter by random ASCII code and generate random text by appending random letters in a loop for given size (4).

Read More
General