C#
Thursday, July 31st, 2008
Is there "c# instanceof"?
It's commonly used in Java. In C# you can use "is" or "as" instead.
if (object is String) will return true if the supplied object is a String.
(object as String) is just another way of casting object to a String.
Posted in C# | No Comments »
Tuesday, July 22nd, 2008
Final keywod for a java class, in c# is replaced by sealed keyword, which means that the class is not available for inheritance.
For variables final in java is the same as readonly in c#: values cannot be modified after initialization, however, they are stored as values.
const in c# is ...
Posted in C#, Java | No Comments »
Saturday, February 23rd, 2008
Verifying credit cards in c# is very easy. The last digit of a credit card is a check digit, which is used to check if the card is valid or not. It prevents the keystroke errors when a check card number is entered.
In this article you will learn about check ...
Posted in C#, Credit Cards, Security | No Comments »
Saturday, February 23rd, 2008
Tired of looking for unregistered domain name? Use this generator written in C# to find available domains, ready to register:
using System;
using System.Text;
using System.Net;
class Domains
{
static Random r = new Random();
static void Main()
{
...
Posted in C#, Domains | No Comments »
Saturday, February 9th, 2008
The best way to generate a unique key is to use System.Guid. The only problem with that is, that it generates string representations, which are 36 characters long. In many cases it is an issue, for example when using it in urls.
The standard GUID representation looks like this:
ae5e6a80-a9e9-4102-a1dd-25697336695e
And it's generated ...
Posted in C# | No Comments »
Friday, November 23rd, 2007
Introduction
Enhanced Exception Handling is one of key features that is most prominently available in .Net both 2003 version and Whidbey versions of C#.
This paper discusses the implementation of Custom Exception Handling using the existing features of C# .Net.
The Concept
The whole idea of having customized Exception Handling is centered around the ...
Posted in C# | No Comments »
Monday, November 19th, 2007
1) Creating the delegate:
public delegate void NumberTooHighDelegate(int Number);
2) Creating the event:
public event NumberTooHighDelegate NumberTooHighEvent;
3) Raising the event:
NumberTooHighEvent(Number1 + Number2);
4) Creating the delegate, creating the event and raising the event should be confined to a given class:
public class MTG {
private int intA, intB;
// ...
Posted in C# | No Comments »
Friday, September 7th, 2007
To display number with commas, so it would look like:
1,200,000
instead of
1200000
you can use String.Format() method.
For Example:
int number = 1200000;
Response.Write(String.Format("{0:#,0}",number));
Posted in C# | No Comments »
Tuesday, September 4th, 2007
Sometimes when you try to input text into database from your C# applications, some of the characters don't show up or show up differently. For Example: apostrophe(') is very often replaced by question mark(?). The same thing happens when you try inserting chinese or japanese characters into database.
The reason of ...
Posted in Asp.Net, C#, Databases | 2 Comments »
Tuesday, September 4th, 2007
The following method removes unwanted html tags from text. It is very useful for removing malicious code from form inputs.
// RemoveHTMLTags method removes *most* malicious code leaving allowed
// HTML in placet
public static string removeHTMLTags(string input)
{
string output = "";
// break the comments ...
Posted in Asp.Net, C#, html | No Comments »