Microsoft has ramped up the security in their latest operating system – Windows Vista, which means that developers now have to pay more attention to certain security constraints imposed by the operating system when developing applications. Those of you readers who have read my prior posts on User Access Control in Vista (and the further reading [...]
Posts Tagged ‘C#’
.NET Wrapper for COM Elevation
Posted in Everything, Software Development, tagged C#, Code, Windows Vista on February 12, 2007 | 11 Comments »
Pass by Reference
Posted in Everything, Software Development, tagged C#, Code on October 25, 2006 | 2 Comments »
Contrary to the beliefs of some developers, .Net reference types do not need to be passed as reference parameters (ref in C#, ByRef in VB) when a method is going to alter the contents of an object instance.
Passing a object reference by reference parameter just means the method can reassign the reference to a new [...]
C# Value Types and Ranges
Posted in Everything, Software Development, tagged C#, Code on June 1, 2006 | Leave a Comment »
Just because it’s good to know…..
Keyword
Class
Range
bool
System.Boolean
true and false
byte
System.Byte
0 to 255
sbyte
System.SByte
-128 to 127
short
System.Int16
-32768 to 32767
ushort
System.Uint16
0 to 65535
int
System.Int32
-2,147,483,648 to 2,147,483,647
uint
System.UInt32
0 to 4,294,967,295
long
System.Int64
-9,223,372,036,854,775,808 to
9,223,372,036,854,775,807
ulong
System.UInt64
0 to 18,446,744,073,709,551,615
decimal
System.Decimal
-79,228,162,514,264,337,593,543,950,335
to 79,228,162,514,264,337,593,543,950,335
double
System.Double
-1.79769313486232e308 to
1.79769313486232e308
float
System.Single
-3.402823e38 to 3.402823e38
char
System.Char
0 to 65535
Access modifiers on property get/set
Posted in Everything, Software Development, tagged C#, Code on February 25, 2006 | 2 Comments »
To some I may be stating the obvious, but today I was happy to find out that C# lets you set a different access level on the get and set for a property. The example below will help to illustrate what I’m talking about:
public DateTime UpdateDate
{
get
{
[...]
From C++ to C#
Posted in Everything, Software Development, tagged C#, Code on November 28, 2005 | 2 Comments »
I have gone back in time this week to work on a legacy ISAPI
application. The ISAPI application is being developed in C++ and
makes use of MSXML to read an XML configuration file. Below is
some code in C++ to open the XML file and read two text values,
contained in element nodes:
BOOL GetConfigDetails(string &userName, string &domain)
{
BOOL result [...]
Multicast Delegate Events as Properties
Posted in Everything, Software Development, tagged C#, Code on October 25, 2005 | Leave a Comment »
The saying goes “you learn something new every day”, and today is no
exception. I’m not sure how I missed this, but never less, this
post shows how to gain finer control over adding and removing of event
handlers to public multicast delegate events.
Typically, most C# developers are used writing event code as follows:
using System;
public delegate void MyDelegate(); [...]
C# 2.0 and the ‘yield’ keyword
Posted in Everything, Software Development, tagged C#, Code on September 13, 2005 | 6 Comments »
Another nice addition to C# 2.0 is the yield keyword. Yield enables iterator blocks to provide values to an enumerated result, see the following example.
// yield-example.cs
using System;
using System.Collections;
public class List
{
public static IEnumerable Power(int number, int exponent)
{
int counter = [...]
Nullable Types in C# 2.0
Posted in Everything, Software Development, tagged C#, Code on August 30, 2005 | 2 Comments »
I was reading about Nullable Types in the C# 2.0 specification for the
.NET Framework 2.0 today. I am surprised I didn’t find out about this
feature long ago, goes to show that you learn something new every day.
So what are Nullable Types?
Simply put, Nullable Types are value types that a can be assigned null. The following [...]
Firing multicast delegate events
Posted in Everything, Software Development, tagged C#, Code on August 17, 2005 | Leave a Comment »
I am currently writing an ASP.NET server control, which exposes a
number of custom events. I was looking through my code archives
for a helper class, which will safely call handler methods of a
multicast delegate, when an event is triggered. I found the class
I was looking for, and decided to publish it here on my blog for [...]
Code Comments
Posted in Everything, Software Development, tagged C#, Code on July 2, 2005 | Leave a Comment »
I have lost count of the number of times that I have been asked to work
on a piece of software written by another developer, only to find out
that the code had no comments. What typically follows is hours spent
wading through lines and lines of complex instruction to determine how
the software was intended to work before [...]