How to set a default property for your class

I’m sorry but that functionality which is known by vb developers couldn’t possible when you are codding in c# .
Also there are some other solutions but its not possible to set a default property for your your class.

you can use indexer but its not that we want:

public string this[int idx]
{
get { … }
set { … }
}

or you can overload  implicit operator to do this but  is also not suggested.


[System.Diagnostics.DebuggerDisplay("{Value}")]
public class MyClass
{

public string Value { get; set; }
    public static implicit operator MyClass(string s)
    {
        return new MyClass { Value = s };
    }

    public static explicit operator string(MyClass f)
    {
        return f.Value;
    }
    public override string ToString()
    {
        return Value;
    }
}

 

Factory Pattern

The factory method pattern is an object-oriented design pattern. Like other creational patterns, it deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The factory method design pattern handles this problem by defining a separate method for creating the objects, whose subclasses can then override to specify thederived type of product that will be created. More generally, the term factory method is often used to refer to any method whose main purpose is creation of objects.

EXAMPLE:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
 
namespace Army
{
    interface ISoldier
    {
        int Rank();
    }
 
    abstract class Soldier : ISoldier
    {
        public abstract int Rank();
    }
 
    class Infantry : Soldier
    {
        override
        public int Rank()
        {
            return 1;
        }
    }
 
    class Marine : Soldier
    {
        override
        public int Rank()
        {
            return 2;
        }
    }
 
    class Commando : Soldier
    {
        override
        public int Rank()
        {
            return 3;
        }
    }
 
    class HeadQuarter
    {
        public enum SoldierType
        {
            Infantry,
            Marine,
            Commando
        }
 
        public static ISoldier createSoldier(SoldierType soldierType)
        {
            switch (soldierType)
            {
                case SoldierType.Infantry:
                    return new Infantry();
                case SoldierType.Marine:
                    return new Marine();
                case SoldierType.Commando:
                    return new Commando();
            }
            throw new ArgumentException("The soldier type " + soldierType + " is not recognized.");
        }
    }
 
    class Troops
    {
        public static void Main(string[] args)
        {
 
            HeadQuarter.SoldierType[] soldierTypes = { HeadQuarter.SoldierType.Commando,
                                                HeadQuarter.SoldierType.Infantry,
                                                HeadQuarter.SoldierType.Marine};
            foreach (HeadQuarter.SoldierType soldierType in soldierTypes)
            {
                System.Console.WriteLine("Rank of " + soldierType + " is " +
                    HeadQuarter.createSoldier(soldierType).Rank());
            }
        }
    }
 
    //Output:
    //Rank of Commando is 3
    //Rank of Infantry is 1
    //rank of Marine is 2
}

Rebuild all indexes in your SQL Server by db names

DECLARE @Database VARCHAR(255)
DECLARE @Table VARCHAR(255)
DECLARE @cmd NVARCHAR(500)
DECLARE @fillfactor INT

SET @fillfactor = 90

DECLARE DatabaseCursor CURSOR FOR
SELECT name FROM master.dbo.sysdatabases
WHERE name IN (‘   ‘)  — [ WRITE HERE YOUR DB NAMES,… ]
ORDER BY 1

OPEN DatabaseCursor

FETCH NEXT FROM DatabaseCursor INTO @Database
WHILE @@FETCH_STATUS = 0
BEGIN

SET @cmd = ‘DECLARE TableCursor CURSOR FOR SELECT table_catalog + ”.” + table_schema + ”.” + table_name as tableName
FROM ‘ + @Database + ‘.INFORMATION_SCHEMA.TABLES WHERE table_type = ”BASE TABLE”’

— create table cursor
EXEC (@cmd)
OPEN TableCursor

FETCH NEXT FROM TableCursor INTO @Table
WHILE @@FETCH_STATUS = 0
BEGIN

SET @cmd = ‘ALTER INDEX ALL ON ‘ + @Table + ‘ REBUILD WITH (FILLFACTOR = ‘ + CONVERT(VARCHAR(3),@fillfactor) + ‘)’
EXEC (@cmd)
FETCH NEXT FROM TableCursor INTO @Table
END

CLOSE TableCursor
DEALLOCATE TableCursor

FETCH NEXT FROM DatabaseCursor INTO @Database
END
CLOSE DatabaseCursor
DEALLOCATE DatabaseCursor

VML & SVG

Vector Markup Language (VML) is an open and standards-based XML language used to producevector graphics.

VML was submitted as a proposed standard to the W3C in 1998 by AutodeskHewlett-Packard,MacromediaMicrosoft, and Visio.[1]

Around the same time other competing W3C submissions were received in the area of web vector graphics, such as PGML from Adobe SystemsSun Microsystems, and others.[2] As a result of these submissions, a new W3C working group was created, which produced SVG.

While Microsoft continues to document VML,[3] development of the format ceased in 1998.[4] VML is implemented in Internet Explorer 5.0 and higher and in Microsoft Office 2000 and higher. Google Mapscurrently uses VML to make vector paths work when running on Internet Explorer 5.5+, and SVG on all other browsers.[5]

The Vector Markup Language is now specified in Part 4 of the Office Open XML standards ISO/IEC29500:2008 and ECMA-376.[6][7]

Scalable Vector Graphics (SVG) is a family of specifications of an XML-based file format for describing two-dimensional vector graphics, both static and dynamic (i.e. interactive or animated).

The SVG specification is an open standard that has been under development by the World Wide Web Consortium (W3C) since 1999.

SVG images and their behaviours are defined in XML text files. This means that they can be searched, indexed, scripted and, if required, compressed. Since they are XML files, SVG images can be created and edited with any text editor, but specialized SVG-based drawing programs are also available.

All major modern web browsers except Microsoft Internet Explorer support and render SVG markup directly.[3] To view SVG files in Internet Explorer, either users have to download and install a browser plugin, or the webmaster can include SVG Web, a JavaScript library currently under development atGoogle Code[4].

SVG is also well-suited to small and mobile devices. The SVG Basic and SVG Tiny specifications were developed with just such uses in mind and many current mobile devices support them.

Source : wikipedia

Together one column’s data in one string

There is a useful expression in T-SQL  “COALESCE()” we can use it for combining a column data into a string easyly

For example

Declare @sumtextnvarchar(100)
select top 5 @sumtext = Coalesce(@sumtext + ‘;’ ,) + Cast(Name as nvarchar)
from Country
print @sumtext

Output:

Afrika;Australi en Nieuw-Zeeland;Belgi;Benelux;Bulgarije;Canada;China;Duitsland;EU-landen;Frankrij

May the code be with you !