Category Archives: C#

Inheritance Simply

Basics are important. Involving in big projects may make us underestimate and forget about the basics. While I was rechecking the important feature of OOP: inheritance, I wanted to share very simple example briefly. My little piece of code here calculates the … Continue reading

Posted in C# | Tagged , | Leave a comment

Simple XML Reading,Writing and Serialization

Altough JSON became more common, XML is still an important markup language. As a snippet, I created an example project which will be creating a Books.xml file and reading it from the file. First of all, let’s create a class called Book with … Continue reading

Posted in C# | Tagged , , | Leave a comment

Basics of LINQ

Some notes on LINQ Language-Integrated Query (LINQ) is the technology that provides tools for developers to use query directly in the programming language (C#). A query is an expression that retrieves data from a data source. In LINQ, you work with objects. You … Continue reading

Posted in C#, LINQ | Tagged | 2 Comments

Thread was being aborted, Response.Redirect

Sometimes, trying to handle exceptions with a statement that redirects the page, we may get a ThreadAbortException error. “If you use the Response.End, Response.Redirect, or Server.Transfer method, a ThreadAbortException exception occurs. You can use a try-catch statement to catch this … Continue reading

Posted in C# | Leave a comment

Check if string contains only numbers

Returns true is the string contains only numbers: private bool allDigitCheck(StringmyString)         {             char[] chars = myString.ToCharArray();             boolallDigit = true;             foreach(char c in chars)             {                 if(!char.IsNumber(c))                 {                     allDigit = false;                 }             … Continue reading

Posted in C# | Leave a comment

Convert an oracle BLOB image (Byte[]) to base64 for web service

while (reader.Read()) {                PhotoInfos myPhoto = new PhotoInfos();                byte[] image = (byte[])reader[“image”];                int imageLength = image.Length;                string base64image = Convert.ToBase64String(image, 0, imageLength);                myPhoto.photo = base64image;                result.Add(myPhoto);                         }

Posted in ASP.NET, C# | Leave a comment

Remove the last character of a StringBuilder object

Updating data depending on the whether or not the parameters are set may cause various problems. For example, In this case, if you send only ID to set, as it will be the last parameter in the query, it may … Continue reading

Posted in ASP.NET, C# | Leave a comment