473,326 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Strange code to me

I have been developing in C# for a few months now and thought I knew the
language but recently I came accross the code pasted below. What is
<Theme>? I don't understand the use of <other than greater than or less
than nor does my C# book have any such code in it.

There is a class named Theme in this program.

Thanks,
T

public static List<ThemeGetThemes()
{
DirectoryInfo dInfo = new
DirectoryInfo(System.Web.HttpContext.Current.Serve r.MapPath("App_Themes"));
DirectoryInfo[] dArrInfo = dInfo.GetDirectories();
List<Themelist = new List<Theme>();
foreach (DirectoryInfo sDirectory in dArrInfo)
{
Theme temp = new Theme(sDirectory.Name);
list.Add(temp);
}
return list;
}
Jul 19 '06 #1
3 1162
Tina,

Its called Generics. Its new in C# 2.0 (part of .NET 2.0/VS 2005).
Basically, GetThemes() returns a List containing elements of type Theme.

For an intro on Generics,
http://msdn.microsoft.com/library/de...p_generics.asp

HTH.

"Tina" <Ti**********@nospamexcite.comwrote in message
news:eh**************@TK2MSFTNGP04.phx.gbl...
I have been developing in C# for a few months now and thought I knew the
language but recently I came accross the code pasted below. What is
<Theme>? I don't understand the use of <other than greater than or less
than nor does my C# book have any such code in it.

There is a class named Theme in this program.

Thanks,
T

public static List<ThemeGetThemes()
{
DirectoryInfo dInfo = new
DirectoryInfo(System.Web.HttpContext.Current.Serve r.MapPath("App_Themes"));
DirectoryInfo[] dArrInfo = dInfo.GetDirectories();
List<Themelist = new List<Theme>();
foreach (DirectoryInfo sDirectory in dArrInfo)
{
Theme temp = new Theme(sDirectory.Name);
list.Add(temp);
}
return list;
}
Jul 19 '06 #2
On Wed, 19 Jul 2006 09:37:03 -0700, "Tina" <Ti**********@nospamexcite.com>
wrote:
>I have been developing in C# for a few months now and thought I knew the
language but recently I came accross the code pasted below. What is
<Theme>? I don't understand the use of <other than greater than or less
than nor does my C# book have any such code in it.

There is a class named Theme in this program.

Thanks,
T

public static List<ThemeGetThemes()
{
DirectoryInfo dInfo = new
DirectoryInfo(System.Web.HttpContext.Current.Serv er.MapPath("App_Themes"));
DirectoryInfo[] dArrInfo = dInfo.GetDirectories();
List<Themelist = new List<Theme>();
foreach (DirectoryInfo sDirectory in dArrInfo)
{
Theme temp = new Theme(sDirectory.Name);
list.Add(temp);
}
return list;
}
This is a declaration of a Generic object. Search for generic in the VS 2005
help. I should mention that Generics are not available in .NET1.0 or .NET 1.1.
The code you are viewing is using .NET 2.0 technology.
Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
Jul 19 '06 #3
"Tina" <Ti**********@nospamexcite.coma écrit dans le message de news:
eh**************@TK2MSFTNGP04.phx.gbl...

|I have been developing in C# for a few months now and thought I knew the
| language but recently I came accross the code pasted below. What is
| <Theme>? I don't understand the use of <other than greater than or less
| than nor does my C# book have any such code in it.
|
| There is a class named Theme in this program.

This is a declaration of a generic list class being bound to the Theme type.

You need to read up on generics.

There is a class called System.Collections.Generic.List<T>; this is a
genreic or template class which can be bound to any type to give you a
typesafe list without having to create a wrapper collection around
ArrayList.

The problem wiht ArrayList is that you can add anything to it and you have
to cast items to the correct type before you can use them. Genreic lists
ensure that the type that the list is bound to is the only type that can be
added to or retrieved from the list.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Jul 19 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Rob Ristroph | last post by:
Hi, It's pretty unhelpful to post "I have a huge piece of code that crashes in strange places, what's the problem?" but that's basically my problem and I really am at my wit's end. The piece...
7
by: M O J O | last post by:
Hi, I'm developing a asp.net application and ran into a strange css problem. I want all my links to have a dashed underline and when they are hovered, it must change to a solid line. Sounds...
25
by: Neil Ginsberg | last post by:
I have a strange situation with my Access 2000 database. I have code in the database which has worked fine for years, and now all of a sudden doesn't work fine on one or two of my client's...
0
by: Kris Vanherck | last post by:
yesterday i started getting this strange error when i try to run my asp.net project: Compiler Error Message: CS0006: Metadata file 'c:\winnt\microsoft.net\framework\v1.1.4322\temporary asp.net...
4
by: Nate Murray | last post by:
Hey all, I'm having a strange PHP (4.3.10) problem that seems to have something to do with javascript. This is a bit complex, so hold on to your hats. My issue is that a single function is...
11
by: Martin Joergensen | last post by:
Hi, I've encountered a really, *really*, REALLY strange error :-) I have a for-loop and after 8 runs I get strange results...... I mean: A really strange result.... I'm calculating...
5
by: Ian | last post by:
Hi everyone, I have found some bizarre (to me...!) behaviour of the Form_Activate function. I have a form which has a button control used to close the form and a subform with a datasheet view...
8
by: Dox33 | last post by:
I ran into a very strange behaviour of raw_input(). I hope somebody can tell me how to fix this. (Or is this a problem in the python source?) I will explain the problem by using 3 examples....
4
by: kj | last post by:
I'm running into a strange seg fault with the module cjson. The strange part is that it does not occur when I run the code under Emacs' Pydb. Here's an example: import sys, cjson d1 =...
20
by: Pilcrow | last post by:
This behavior seems very strange to me, but I imagine that someone will be able to 'explain' it in terms of the famous C standard. -------------------- code -----------------------------------...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.