Showing posts with label type. Show all posts
Showing posts with label type. Show all posts

Monday, July 12, 2010

C# Prefix Casting vs 'as' Casting

The main difference between the two types of casting is what happens when an error occurs.

Prefix Casting: In prefix casting [ Type myVar = (Type)someVar; ] an error will be thrown and must be caught if someVar is not actually of type 'Type'.

'as' Casting: In as casting [ Type myVar = someVar as Type; ] the cast will return 'null' if someVar is not of type 'Type'.

I've read that 'as' Casting is also about five times faster (5x) than prefix casting. I've run my own tests and found out that it really isn't. Or at least not in loops. I've tried converting both 'string' and 'DateTime' objects to object. Prefix was much faster when adding to a list and sometimes faster when just converting the value to another variable.


Thursday, June 24, 2010

DataTable Column Mapping for XML

This article will demonstrate how to determine or set a SYSTEM.DATA.DATATABLE.Column as different XML nodes.

// The user must include into their class:
using System.Data;

// ==========
// To determine if a column is an XML attribute after
// loading data

// --- after loading data into the dataset
// --- and finding the table needed
mytable.Columns[].ColumnMapping == MappingType.;

----> There are 4 types
Attribute
Element
Hidden
SimpleType

Columns.MappingType Gets or Sets the mapping type for the column.

Thursday, June 17, 2010

TypeTester

This is a site to test Fonts side-by-side.

Really helpful.


This shows what types look like on different machines.