Grounding.co.za

Technology information for IT specialists
Welcome to Grounding.co.za Sign in | Join | Help
in Search

Tech Talk with Brett Maytom

April 2008 - Posts

  • Microsoft Visual Studio 2008 certifications heads up

    Microsoft Learning has introduced the new Visual Studio 2008 certifications, although these exams are still in beta or about to go into beta this is the roadmap ahead of you.  Some of the exams are still in beta for the next few weeks if you are game to do them.

    In a nutshell:

    • There are 6 MCTS exams on different framework aspects of the .NET framework
      • MCTS: .NET Framework 3.5, Windows Presentation Foundation Applications
      • MCTS: .NET Framework 3.5, Windows Communication Foundation Applications
      • MCTS: .NET Framework 3.5, Windows Workflow Foundation Applications
      • MCTS: .NET Framework 3.5, Windows Forms Applications
      • MCTS: .NET Framework 3.5, ADO.NET Applications
      • MCTS: .NET Framework 3.5, ASP.NET Applications
    • You still need to write the core exam 70-536: TS: Microsoft .NET Framework 2.0 – Application Development Foundation
    • MCPD still have the same three categories (again you need to do the MCTS exams in each area first)
      • MCPD: Windows Developer 3.5
      • MCPD: ASP.NET Developer 3.5
      • MCPD: Enterprise Application Developer 3.5

    I will keep you posted as more exam details come out.

    References

    1. http://www.microsoft.com/learning/mcp/vstudio/2008/default.mspx
    2. http://blogs.msdn.com/trika/archive/2008/04/18/net-framework-3-5-certifications.aspx
  • System.Object Equals Method

    The Equals method is used to determine equality of two objects, however the way it does this differs from reference an value type objects.  For value type objects (structures)  the actual values of the structure is compared, i.e. its state is compared. For reference type objects, equality is determined whether the two objects are pointing to the same object in memory, thus the actual state is not compared. 

    For the purposes of demonstration, the following co-ordinate class has been created with an X and Y co-ordinate

    image 

       1: /// <summary>
       2: /// The point class represents a X and Y coordinate
       3: /// </summary>
       4: public class Point
       5: {
       6:     #region // Fields
       7:  
       8:     private int _x;
       9:     private int _y;
      10:  
      11:     #endregion
      12:  
      13:     #region // Properties
      14:  
      15:     /// <summary>
      16:     /// The x coordinate.
      17:     /// </summary>
      18:     public int X { get { return _x; } set { _x = value; } }
      19:  
      20:     /// <summary>
      21:     /// The y coordinate.
      22:     /// </summary>
      23:     public int Y { get { return _y; } set { _y = value; } }
      24:  
      25:     #endregion
      26:  
      27:     #region // Constructor
      28:  
      29:     #region // -  ctor(int, int)
      30:  
      31:     /// <summary>
      32:     /// Initialises the point to the values of x and y.
      33:     /// </summary>
      34:     /// <param name="x">The initial value of the x coordinate.</param>
      35:     /// <param name="y">The initial value of the y coordinate.</param>
      36:     public Point(int x, int y)
      37:     {
      38:         _x = x;
      39:         _y = y;
      40:     }
      41:  
      42:     #endregion
      43:  
      44:     #endregion
      45:  
      46:     #region // System.Object overrides
      47:  
      48:     #region // -  ToString
      49:  
      50:     /// <summary>
      51:     /// This method converts the point to a string.
      52:     /// </summary>
      53:     /// <returns>Returns a string representation of the x and y cordinates</returns>
      54:     public override string ToString()
      55:     {
      56:         return string.Format("(x={0},y={1})", _x, _y);
      57:     }
      58:     
      59:     #endregion
      60:  
      61:     #endregion
      62: }

    The problem

    Create the following test program

       1: /// <summary>
       2: /// The demonstration console application
       3: /// </summary>
       4: class Program
       5: {
       6:     static void Main(string[] args)
       7:     {
       8:         // Create a Point reference varialble to point new object on the heap for point 3,5
       9:         Point A = new Point(3, 5);
      10:         // Create a Point reference varialble to point new object on the heap for point 8,6 
      11:         Point B = new Point(8, 6);
      12:         // Create a Point reference variable and point it to the same heap object as A
      13:         Point C = A;
      14:         // Create a Point reference varialble to point new object on the heap for point 3,5
      15:         Point D = new Point(3, 5);
      16:  
      17:         Console.WriteLine("A {1} == B {2} : {0}", (A==B),A,B);
      18:         Console.WriteLine("A {1} == C {2} : {0}", (A == C),A,C);
      19:         Console.WriteLine("A {1} == D {2} : {0}", (A == D),A,D);
      20:     }
      21: }

    Run the program an you get the following result

    image

    Note that A and C are equal as they point to the same object on the heap.  However, A and D are not equal even though the values are the same, the reason for this is they are different objects on the heap!  Remember that when comparing reference types, the reference to the heap is compared and NOT the values.

    image

    This is a problem if you actually want to compare the values, well in .NET you can, read the solution below.

    The solution

    If you want to compare different objects on the heap and equality is important for you, you are going to have to override the Equals method. Overriding this is not good enough as most programmers do not type code like if( a.Equals(b) ), and would rather type if( a == b ).  Thus you will land up creating an the operator==, however the bad news is you will also need to create the operator !=.

    Thus when comparing objects you will have to create three methods, these are listed below:

    Override the Equals Method

    The first step is to override the Equals method of system object.  This method should compare the current object with the passed object to determine whether the fields are the same.  In my example I will check this.X == obj.X a and this.Y ==  obj.Y, when both are the same I will return true otherwise I will also return false. 

    You will also not that the Equals operator passes an object, so the first thing to do is determine whether we are comparing a Point with a Point.   The nice little trick here is obj is Point will return false if obj == null, thus we are ensuring the object is not null and is a point.

       1: #region // -  Equals
       2:  
       3: /// <summary>
       4: /// This method compares the equality of two objects
       5: /// </summary>
       6: /// <param name="obj"></param>
       7: /// <returns></returns>
       8: public override bool Equals(object obj)
       9: {
      10:     if (obj is Point)
      11:     {
      12:         Point rhs = (Point)obj;
      13:         return (this._x == rhs._x && this._y == rhs._y);
      14:     }
      15:  
      16:     return false;
      17: }
      18:  
      19: #endregion

    Create the operator==

    This is nice however the == operator still will not return what we expected, thus we have to create the == operator.  Create the operator by adding the following code to the project

       1: #region // -  operator==
       2:  
       3: /// <summary>
       4: /// The equals operator compares two points and uses the Equals method
       5: /// </summary>
       6: /// <param name="lhs">The object on the left-hand-side of the operator.</param>
       7: /// <param name="rhs">The object on the right-hand-side of the operator.</param>
       8: /// <returns>Returns true if the x,y coordinates are the same.</returns>
       9: public static bool operator ==(Point lhs, Point rhs)
      10: {
      11:     if (null == (object)lhs)
      12:         return false;
      13:     return lhs.Equals(rhs);
      14: }
      15:  
      16: #endregion

     

    There is a bit of ugly code here that you need to be aware of, that is on line 11.  This is to make sure that the lhs argument is not null and to prevent lhs.Equals(rhs) throwing an NullReferenceException if it is null.  The ugly comes in the fact that if you had typed if (null == rhs), you would get recursive method execution method and a StackOverflowException, hence the cast (object)lhs, causing the objects operator== to execute.

    Create the operator!=

    When you create the operator==, you have to also code the operator!=, so you will have to add this code

     
       1: #region // -  operator!=
       2:  
       3: /// <summary>
       4: /// The not equals operator compares that inequality of two operators
       5: /// </summary>
       6: /// <param name="lhs">The object on the left-hand-side of the operator.</param>
       7: /// <param name="rhs">The object on the right-hand-side of the operator.</param>
       8: /// <returns>Returns true if the x,y coordinates are not the same.</returns>
       9: public static bool operator !=(Point lhs, Point rhs)
      10: {
      11:     if (null == (object)lhs) 
      12:         return false;
      13:     return !lhs.Equals(rhs);
      14:     
      15: }
      16:  
      17: #endregion

    As with the operator==, we need to make sure that lhs is an object and prevent a recursive call.

    The test

    Compile and run your test application, this time you will notice that A == D is also true.

    image 

    Summary

    In summary if you are wanting to compare two different objects on the heap, i.e. reference type objects that contain the same data, you will have to override the Equals method of System.Object, then also create operator== and operator!=.   You will still be able to check whether the objects are physically the same object in memory by using object.ReferenceEquals.

    Posted Apr 12 2008, 01:14 PM by Brett with no comments
    Filed under: ,
  • SharePoint - The TEMPLATE folder in the 12 Hive

    As a developer learning how to provision your custom solutions to SharePoint, you will come across the TEMPLATE directory within the 12 hive.  It is exceptionally important that you master what is in the directory and where to put your own resources.  This blog post will attempt to help you master what is in the TEMPLATE directory structure.

    Spend a bit of time exploring this on your own machine and having a look at the contents as this will certainly be time well spent.

    TEMPLATE\LCID

    SharePoint is an international product and supports globalisation.  You are able to localise your site to any supported language.  The LCID is the local identifier for a language and is commonly used through windows programming.  Refer to my post SharePoint Locale ID (LCIDS) Table.

    TEMPLATE\LCID\STS

    The directory contains a set of default template documents for various packages such as word, excel, one note and many others.  These templates are automatically used when creating a new document within a document library.

    TEMPLATE\LCID\Workflow

    The directory contains manifest files for workflow templates.

    TEMPLATE\LCID\XML

    The directory contains several XML files with language specific text for default e-mails, regional settings.  The global configuration file for the global template resides in this folder.

    TEMPLATE\Admin

    The Admin folder contains the application pages for the Central Administration site.

    TEMPLATE\ControlTemplates

    This directory contains a set of common composite server side controls (ascx) files that are used in pages as well on the master pages.

    TEMPLATE\DocumentTemplates

    This folder contains template pages used when provisioning templates.  The only page is in WSS the template aspx for a wiki page.

    TEMPLATE\Features

    This vital directory is where all the various sharepoint features will be deployed to, including your own.  Each feature is deployed into its own folder, I would suggest that you create your feature in a directory[company].[Feature name] as to eliminate naming conflicts.

    TEMPLATE\Features\[feature]

    Each feature directory will contain the feature manifest file, typically this would be feature.xml.

    TEMPLATE\Global

    This directory contains the global master page (also mobile pages), all the fields definitions that are global to all sites and the global site definitions.

    TEMPLATE\Images

    Contains images shared by all pages on the server, addressed by the virtual directory /_layouts/images.

    TEMPLATE\Layouts

    This directory structure is contains application pages, application master pages, cascading style sheets, java scripts. Th directory is exposted as a virtual directory /_layouts on all web applications, this directory contains language subdirectories that contain the forms for creating lists, site administration pages, and so on. These directories are shared by all sites.

    TEMPLATE\Layouts\LCID

    Contains forms for creating lists, site administration pages, and so on, for a specific language.

    TEMPLATE\Layouts\LCID\Images

    This folder contains regional specific images used by the style sheets as well as images used on application pages.

    TEMPLATE\Layouts\LCID\Styles

    This folder contains regional specific cascading style sheets used by templates within the site.  The important style sheet to note is the core.css file.

    TEMPLATE\Layouts\Mobile

    The directory contains application pages specific to mobile devices.

    TEMPLATE\Layouts\Style

    The directory contains style sheets used by pages that are not local specific.

    TEMPLATE\Pages

    The directory contains several site page files.

    TEMPLATE\SiteTemplates

    The directory contains a set of directories for different templates deployed into sharepoint.  Each template is in a subdirectory

    TEMPLATE\SiteTemplates\[template]

    Each template is installed in its own  sub directory with possible supporting files.

    TEMPLATE\SiteTemplates\[template]\xml

    Each template has an xml sub directory with the important ONET.xml file.  This manifest describes the template and the different configurations within the template.

    TEMPLATE\SQL

    The SQL folder contains a set of T-SQL files used to create the necessary database schemas for the various SharePoint databases.

    TEMPLATE\Themes

    This directory contains the list of themes which allows you to change the basic colour scheme and branding of the site.  However, these themes are strongly coupled to the default.master and other master pages as well as the core.css file.  Each directory will also contain graphic resources 

    XML

    Contains various xml schema files that define Collaborative Application Markup Language. These files are particularly useful to copy to the xml editors such as Visual Studio, thus allowing validation and intelli-sense.

    See

    See Also

    Posted Apr 09 2008, 10:28 PM by Brett with 2 comment(s)
    Filed under:
  • SharePoint Locale ID (LCID) Table

    Windows uses a Locale Identifier (LCID) to determine the language and culture to use when displaying information to a user.  The users LCID is picked up from his/her regional settings within windows or from the language settings for the browser.  The application then displays resources, number and date formatting according to the the local.  This post lists a table of LCID's, the short name and full name of each locale.

    All products, such as SharePoint, SQL, .NET all use this to assist with formatting.  As this post is focusing on LCIDS in SharePoint, there are several folders within the 12 hive that allow you to globalise and localise your application.

    \BIN\LCID
    SharePoint deploys local specific dll's for custom messages used within the SharePoint framework.  You will typically not be updating this folder with your own DLL's.
    \HCCab\LCID
    You are able to create and deploy your own help files that integrate into the SharePoint help system.  Doing this is not the simplest of tasks and does require a very specific way to deploy your help files.
    \Help\LCID  
      This folder contains a compiled help file (.chm) that is used when installing SharePoint.  There is no need for you to change this folder.
    \TEMPLATE\LCID  
    SharePoint is an international product and supports globalisation.  You are able to localise your site to any supported language.  The LCID is the local identifier for a language and is commonly used through windows programming.
    \TEMPLATE\LAYOUTS\LCID  
    The layouts folder contains application pages and there is a LCID folder for each language.  This LCID folder contains localised java scripts, cascading style sheets and images used in the application page. 
    \TEMPLATE\SQL\LCID  
    Localised default script and data used when the SharePoint provisioning engine creates a database.
    \ISAPI\HELP\LCID  
    Help content for the SharePoint web services.

    Table of locals

    Locale Description

     

     

     

     

    Short String

     

     

     

     

    Decimal Value

     

     

     

     

    Afrikaans

     

     

     

    af

     

     

     

    1078

     

     

     

    Albanian

     

     

     

    sq

     

     

     

    1052

     

     

     

    Arabic - United Arab Emirates

     

     

     

    ar-ae

     

     

     

    14337

     

     

     

    Arabic - Bahrain

     

     

     

    ar-bh

     

     

     

    15361

     

     

     

    Arabic - Algeria

     

     

     

    ar-dz

     

     

     

    5121

     

     

     

    Arabic - Egypt

     

     

     

    ar-eg

     

     

     

    3073

     

     

     

    Arabic - Iraq

     

     

     

    ar-iq

     

     

     

    2049

     

     

     

    Arabic - Jordan

     

     

     

    ar-jo

     

     

     

    11265

     

     

     

    Arabic - Kuwait

     

     

     

    ar-kw

     

     

     

    13313

     

     

     

    Arabic - Lebanon

     

     

     

    ar-lb

     

     

     

    12289

     

     

     

    Arabic - Libya

     

     

     

    ar-ly

     

     

     

    4097

     

     

     

    Arabic - Morocco

     

     

     

    ar-ma

     

     

     

    6145

     

     

     

    Arabic - Oman

     

     

     

    ar-om

     

     

     

    8193

     

     

     

    Arabic - Qatar

     

     

     

    ar-qa

     

     

     

    16385

     

     

     

    Arabic - Saudi Arabia

     

     

     

    ar-sa

     

     

     

    1025

     

     

     

    Arabic - Syria

     

     

     

    ar-sy

     

     

     

    10241

     

     

     

    Arabic - Tunisia

     

     

     

    ar-tn

     

     

     

    7169

     

     

     

    Arabic - Yemen

     

     

     

    ar-ye

     

     

     

    9217

     

     

     

    Armenian

     

     

     

    hy

     

     

     

    1067

     

     

     

    Azeri - Latin

     

     

     

    az-az

     

     

     

    1068

     

     

     

    Azeri - Cyrillic

     

     

     

    az-az

     

     

     

    2092

     

     

     

    Basque

     

     

     

    eu

     

     

     

    1069

     

     

     

    Belarusian

     

     

     

    be

     

     

     

    1059

     

     

     

    Bulgarian

     

     

     

    bg

     

     

     

    1026

     

     

     

    Catalan

     

     

     

    ca

     

     

     

    1027

     

     

     

    Chinese - China

     

     

     

    zh-cn

     

     

     

    2052

     

     

     

    Chinese - Hong Kong SAR

     

     

     

    zh-hk

     

     

     

    3076

     

     

     

    Chinese - Macau SAR

     

     

     

    zh-mo

     

     

     

    5124

     

     

     

    Chinese - Singapore

     

     

     

    zh-sg

     

     

     

    4100

     

     

     

    Chinese - Taiwan

     

     

     

    zh-tw

     

     

     

    1028

     

     

     

    Croatian

     

     

     

    hr

     

     

     

    1050

     

     

     

    Czech

     

     

     

    cs

     

     

     

    1029

     

     

     

    Danish

     

     

     

    da

     

     

     

    1030

     

     

     

    Dutch - The Netherlands

     

     

     

    nl-nl

     

     

     

    1043

     

     

     

    Dutch - Belgium

     

     

     

    nl-be

     

     

     

    2067

     

     

     

    English - Australia

     

     

     

    en-au

     

     

     

    3081

     

     

     

    English - Belize

     

     

     

    en-bz

     

     

     

    10249

     

     

     

    English - Canada

     

     

     

    en-ca

     

     

     

    4105

     

     

     

    English - Caribbean

     

     

     

    en-cb

     

     

     

    9225

     

     

     

    English - Ireland

     

     

     

    en-ie

     

     

     

    6153

     

     

     

    English - Jamaica

     

     

     

    en-jm

     

     

     

    8201

     

     

     

    English - New Zealand

     

     

     

    en-nz

     

     

     

    5129

     

     

     

    English - Phillippines

     

     

     

    en-ph

     

     

     

    13321

     

     

     

    English - South Africa

     

     

     

    en-za

     

     

     

    7177

     

     

     

    English - Trinidad

     

     

     

    en-tt

     

     

     

    11273

     

     

     

    English - United Kingdom

     

     

     

    en-gb

     

     

     

    2057

     

     

     

    English - United States

     

     

     

    en-us

     

     

     

    1033

     

     

     

    Estonian

     

     

     

    et

     

     

     

    1061

     

     

     

    Farsi

     

     

     

    fa

     

     

     

    1065

     

     

     

    Finnish

     

     

     

    fi

     

     

     

    1035

     

     

     

    Faroese

     

     

     

    fo

     

     

     

    1080

     

     

     

    French - France

     

     

     

    fr-fr

     

     

     

    1036

     

     

     

    French - Belgium

     

     

     

    fr-be

     

     

     

    2060

     

     

     

    French - Canada

     

     

     

    fr-ca

     

     

     

    3084

     

     

     

    French - Luxembourg

     

     

     

    fr-lu

     

     

     

    5132

     

     

     

    French - Switzerland

     

     

     

    fr-ch

     

     

     

    4108

     

     

     

    Gaelic - Ireland

     

     

     

    gd-ie

     

     

     

    2108

     

     

     

    Gaelic - Scotland

     

     

     

    gd

     

     

     

    1084

     

     

     

    German - Germany

     

     

     

    de-de

     

     

     

    1031

     

     

     

    German - Austria

     

     

     

    de-at

     

     

     

    3079

     

     

     

    German - Liechtenstein

     

     

     

    de-li

     

     

     

    5127

     

     

     

    German - Luxembourg

     

     

     

    de-lu

     

     

     

    4103

     

     

     

    German - Switzerland

     

     

     

    de-ch

     

     

     

    2055

     

     

     

    Greek

     

     

     

    el

     

     

     

    1032

     

     

     

    Hebrew

     

     

     

    he

     

     

     

    1037

     

     

     

    Hindi

     

     

     

    hi

     

     

     

    1081

     

     

     

    Hungarian

     

     

     

    hu

     

     

     

    1038

     

     

     

    Icelandic

     

     

     

    is

     

     

     

    1039

     

     

     

    Indonesian

     

     

     

    id

     

     

     

    1057

     

     

     

    Italian - Italy

     

     

     

    it-it

     

     

     

    1040

     

     

     

    Italian - Switzerland

     

     

     

    it-ch

     

     

     

    2064

     

     

     

    Japanese

     

     

     

    ja

     

     

     

    1041

     

     

     

    Korean

     

     

     

    ko

     

     

     

    1042

     

     

     

    Latvian

     

     

     

    lv

     

     

     

    1062

     

     

     

    Lithuanian

     

     

     

    lt

     

     

     

    1063

     

     

     

    FYRO Macedonian

     

     

     

    mk

     

     

     

    1071

     

     

     

    Malay - Malaysia

     

     

     

    ms-my

     

     

     

    1086

     

     

     

    Malay – Brunei

     

     

     

    ms-bn

     

     

     

    2110

     

     

     

    Maltese

     

     

     

    mt

     

     

     

    1082

     

     

     

    Marathi

     

     

     

    mr

     

     

     

    1102

     

     

     

    Norwegian - Bokmål

     

     

     

    no-no

     

     

     

    1044

     

     

     

    Norwegian - Nynorsk

     

     

     

    no-no

     

     

     

    2068

     

     

     

    Polish

     

     

     

    pl

     

     

     

    1045

     

     

     

    Portuguese - Portugal

     

     

     

    pt-pt

     

     

     

    2070

     

     

     

    Portuguese - Brazil

     

     

     

    pt-br

     

     

     

    1046

     

     

     

    Raeto-Romance

     

     

     

    rm

     

     

     

    1047

     

     

     

    Romanian - Romania

     

     

     

    ro

     

     

     

    1048

     

     

     

    Romanian - Republic of Moldova

     

     

     

    ro-mo

     

     

     

    2072

     

     

     

    Russian

     

     

     

    ru

     

     

     

    1049

     

     

     

    Russian - Republic of Moldova

     

     

     

    ru-mo

     

     

     

    2073

     

     

     

    Sanskrit

     

     

     

    sa

     

     

     

    1103

     

     

     

    Serbian - Cyrillic

     

     

     

    sr-sp

     

     

     

    3098

     

     

     

    Serbian - Latin

     

     

     

    sr-sp

     

     

     

    2074

     

     

     

    Setsuana

     

     

     

    tn

     

     

     

    1074

     

     

     

    Slovenian

     

     

     

    sl

     

     

     

    1060

     

     

     

    Slovak

     

     

     

    sk

     

     

     

    1051

     

     

     

    Sorbian

     

     

     

    sb

     

     

     

    1070

     

     

     

    Spanish - Spain

     

     

     

    es-es

     

     

     

    1034

     

     

     

    Spanish - Argentina

     

     

     

    es-ar

     

     

     

    11274

     

     

     

    Spanish - Bolivia

     

     

     

    es-bo

     

     

     

    16394

     

     

     

    Spanish - Chile

     

     

     

    es-cl

     

     

     

    13322

     

     

     

    Spanish - Colombia

     

     

     

    es-co

     

     

     

    9226

     

     

     

    Spanish - Costa Rica

     

     

     

    es-cr

     

     

     

    5130

     

     

     

    Spanish - Dominican Republic

     

     

     

    es-do

     

     

     

    7178

     

     

     

    Spanish - Ecuador

     

     

     

    es-ec

     

     

     

    12298

     

     

     

    Spanish - Guatemala

     

     

     

    es-gt

     

     

     

    4106

     

     

     

    Spanish - Honduras

     

     

     

    es-hn

     

     

     

    18442

     

     

     

    Spanish - Mexico

     

     

     

    es-mx

     

     

     

    2058

     

     

     

    Spanish - Nicaragua

     

     

     

    es-ni

     

     

     

    19466

     

     

     

    Spanish - Panama

     

     

     

    es-pa

     

     

     

    6154

     

     

     

    Spanish - Peru

     

     

     

    es-pe

     

     

     

    10250

     

     

     

    Spanish - Puerto Rico

     

     

     

    es-pr

     

     

     

    20490

     

     

     

    Spanish - Paraguay

     

     

     

    es-py

     

     

     

    15370

     

     

     

    Spanish - El Salvador

     

     

     

    es-sv

     

     

     

    17418

     

     

     

    Spanish - Uruguay

     

     

     

    es-uy

     

     

     

    14346

     

     

     

    Spanish - Venezuela

     

     

     

    es-ve

     

     

     

    8202

     

     

     

    Sutu

     

     

     

    sx

     

     

     

    1072

     

     

     

    Swahili

     

     

     

    sw

     

     

     

    1089

     

     

     

    Swedish - Sweden

     

     

     

    sv-se

     

     

     

    1053

     

     

     

    Swedish - Finland

     

     

     

    sv-fi

     

     

     

    2077

     

     

     

    Tamil

     

     

     

    ta

     

     

     

    1097

     

     

     

    Tatar

     

     

     

    tt

     

     

     

    1092

     

     

     

    Thai

     

     

     

    th

     

     

     

    1054

     

     

     

    Turkish

     

     

     

    tr

     

     

     

    1055

     

     

     

    Tsonga

     

     

     

    ts

     

     

     

    1073

     

     

     

    Ukrainian

     

     

     

    uk

     

     

     

    1058

     

     

     

    Urdu

     

     

     

    ur

     

     

     

    1056

     

     

     

    Uzbek - Cyrillic

     

     

     

    uz-uz

     

     

     

    2115

     

     

     

    Uzbek – Latin

     

     

     

    uz-uz

     

     

     

    1091

     

     

     

    Vietnamese

     

     

     

    vi

     

     

     

    1066

     

     

     

    Xhosa

     

     

     

    xh

     

     

     

    1076

     

     

     

    Yiddish

     

     

     

    yi

     

     

     

    1085

     

     

     

    Zulu

     

     

     

    zu

     

     

     

    1077

     

     

     

    See

    Posted Apr 09 2008, 11:02 AM by Brett with no comments
    Filed under:
  • System.Object

    Learning your language for .NET programming is a challenge in its own right, learning to use and exploit the .NET framework to its fullest is even harder due the mere fact of the size of the framework.  However, there is one class in the framework you should master and that is the System.Object class.  

    System.Object defines the basic behaviour of all managed data types and thus all managed data types within the framework, be it a value or reference types.  Every managed type inherits from System.Object, either directly or indirectly.  A reference type (class) may inherit from another explicit class, however ultimately they all will inherit from System.Object.

    Reference Types and System.Object

    Take the following set of classes:

    class Animal
    { }

    class Mammal : Animal
    { }

    class Dog : Mammal
    { }

    image

    Dog inherits from Mammal, thus dog gains all characteristics of a Mammal and its own members.  Mammal however inherits from animal, thus both Dog and Mammal get all the characteristics of the Animal.  In this example, Animal does not inherit from anything explicitly.  Don't be fooled by this as in reality Animal does inherit from system object.  You may have written the class

    class Animal: System.Object
    { }

    In C#, the keyword object is an alias for System.Object, thus the code below is the same as above.

    class Animal : object
    { }

    Value Types and System.Object

    Value types (struct) on the other hand do not support inheritance directly, let us take the following value type as an example:

    struct Point
    { }

    This struct automatically inherits from System.ValueType (a class) which in turn inherits from System.Object.  Thus one could theoretically say that a structure is a class, however it has a different memory model to a class. 

    image

    System.Object Members

    Now we all know the rules, and it is not necessary for you to explicitly inherit from object.  It is automatically implied and all .NET programmers should know this.  This section now describes the member methods of the System.Object class and answers the begging question of what you can do with it.

    Constructor
    public Object();

     

    The default constructor of System.Object is called every time an instance of an object is created.  The System.Object only has a default constructor (no parameters).   Equals
    public virtual bool Equals(object obj)
    public static bool Equals(object objA, object objB)

     

    The Equals method is used to compare whether two objects are in fact the identical.  However, there is a twist to their tail.  For reference type objects, the objects identity is actually checked, i.e. Are they the same physical object in memory?.  Value Types are different as a compare will check the state, i.e. The actual values are compared.  It is common practice to override the Equals method to perform proper equality checking.   Finalize
    public override void Finalize()

    This method is called on every instance of objects in memory when the garbage collector is in the process of freeing the memory.  This method will then be used to free up unmanaged resources used by the object.  In C#, you will not be able to override this directly as other methods as Finalize is implemented as a destructor ~Class().  When you compile your project and view the MSIL you will notice that ~Class() will be converted into a Finalize method.

    GetHashCode
    public virtual int GetHashCode()

     

    A hash code is normally created to uniquely identify the object.  A default hash code is automatically generated when an object is created, this has code may have some interesting issues.  Firstly hash codes are not evenly distributed, that is they are not sequential and completely random.  Secondly the default hash code is not guaranteed to be unique.  These has codes are often used in collections to uniquely define a key or whether an object exists.   In reality the likelihood of two hash codes being the same is slim,  You will be able to override and generate your own hash code that uniquely identifies the object. GetType
    public Type GetType()

    This method returns at System.Type reference to the object. This nifty little method allows you to then inspect the data type and programmatically work with the data type.  It thus returns the metadata of your object. I.e.  You will write code to interrogate the data type and adjust accordingly, welcome to the start of Reflection.

    MemberWiseClone
    protected object MemberwiseClone()

     

    MemberwiseClone is used to create a new copy of the object.  It is a protected method and thus can only be accessed from child classes.  It cannot be overridden.  MemberwiseClone creates what we call a shallow copy, it will copy the data from the object to the clone.  Value type member fields will have their data copied, however, reference type member objects will only have their object references copied.  I.e.  Should you clone a object that has a member which is a reference type, both the original and the clone will point to the same member of Reference type.   ReferenceEquals
    public static bool ReferenceEquals(object objA, object objB)

     

    This method compares whether two object reside at the same memory location, their values or state are not compared.   ToString
    public virtual string ToString()

    The ToString() method is used to return a string representation of the current instance.  The default behaviour of this method is to return the fully qualified name of the Type.  Override this method to implement a better representation of data of your method.

    Posted Apr 04 2008, 10:37 PM by Brett with no comments
    Filed under: ,
More Posts
Add to Technorati Favorites
Powered by Community Server (Commercial Edition), by Telligent Systems
Afrigator