Browse by Tags
All Tags
»
Generics
-
.NET Misc.
-
Announcements
-
C#
-
Data Access
-
GridView
-
What's wrong with this code?
Group ( Of Experts) Generics is one of the most noted changes to the .NET Framework 2.0. Generics will reduce overhead due to boxing/unboxing and the amount of errors in your code . Want to learn about .NET Generics but don't know where to start? Join
Read More...
Today I answered a thread regarding using generics with XML and it reminded me of the following blog entry regarding XML generics in .NET 3.0: XML Generics
Read More...
I answered a post on the ASP.NET forums where somebody was having problems with Generics and class inheritence. I ended up cooking this up as an example based upon what they had already provided in the thread. using System; using System.Collections.Generic;
Read More...
I just answered a thread where somebody wanted to know how to take any nullable type, check if it's value is null, and depending on that either return String.Empty or ToString. Here's how you do that: public static string ConvertNullableToString
(T?
Read More...
Earlier today I answered a question on a group where some guy was trying to use nullable types with a typed DataSet. Unfortunately, this feature was cut out at the last moment. But, there is a way around this. Adding Functionality to a Typed DataSet using
Read More...
I put together sample code that will run on the Northwind database that demonstrates using a generic List collection as a data source for an ObjectDataSource which populates a GridView control. All you have to do is specify the connection string in Web.config
Read More...
Using String.Format you can format any string. However, the last parameter that String.Format accepts is of type object. So, to add some type-safety to the mix, the following function works perfectly. VB.NET Public Function FormatString( Of T)( ByVal
Read More...
Let's say for instance, you want to create a List of your own class, say Employee, where Employee represents an employee. First, we'll start by creating an employee class. [ Serializable ] public class Employee { private bool m_IsSalaried; private int
Read More...
I was surfing the Internet today and came across David Wheeler's blog, which has some interesting entries on Generics. Anonymous methods and handling events in .NET 2.0 Generics: An introduction Generics: More advanced concepts New and improved event
Read More...
Take the following code, for example: VB.NET Public Class TestClass( Of T) End Class Response.Write(GetType(TestClass( Of Integer ))) C# public class TestClass
{ } Response.Write( typeof ( TestClass < int >)); The above code results in
Read More...
Q: What's wrong with the below generic class? VB.NET Imports System.Data Imports System.Web Public Class GenericClass( Of T As DataTable) Public Function GetValue( ByVal val As T) As T Return val End Function Public Function GetValue( ByVal val As T)
Read More...
In generics, you can use sub classes just as you would any non-generic sub class. Take the following class and sub class for example: VB.NET Public Class OuterClass( Of T, U, V) Public Class InnerClass( Of T, U) Public Function InnerMethod( ByVal val1
Read More...
One of the weirder features in C# 2.0 is nullable types. My thinking is as follows: Why complicate things with Nullable
, or its shorter version of DataType? (i.e. int?), instead of allowing null values to be assigned to those data types that
Read More...
One of the cooler features I like in Generics is type inference. Type inference allows you to call a generic method just as you would a non-generic method using its method signatures as references to the type(s), instead of specifying the type(s). VB.NET
Read More...
I love mysteries. However, this one is pretty simple. Q: What is wrong with the following generic type? VB.NET Public Class BaseClass( Of K, V) End Class Public Class SubClass1 Inherits BaseClass( Of K, V) End Class Public Class SubClass2 Inherits BaseClass(
Read More...