Click here to Skip to main content
15,923,376 members
Home / Discussions / C#
   

C#

 
GeneralRe: RegEx for Fist Charactr is Positive Pin
Luc Pattyn26-May-11 13:01
sitebuilderLuc Pattyn26-May-11 13:01 
GeneralRe: RegEx for Fist Charactr is Positive Pin
Manfred Rudolf Bihy26-May-11 13:25
professionalManfred Rudolf Bihy26-May-11 13:25 
AnswerRe: RegEx for Fist Charactr is Positive Pin
BobJanova26-May-11 23:33
BobJanova26-May-11 23:33 
QuestionExecuting Javascript Pin
mjackson1126-May-11 10:00
mjackson1126-May-11 10:00 
AnswerRe: Executing Javascript Pin
BobJanova26-May-11 23:38
BobJanova26-May-11 23:38 
QuestionHow to combine 3 different list objects into a single list object? Pin
Goalie3526-May-11 5:48
Goalie3526-May-11 5:48 
AnswerRe: How to combine 3 different list objects into a single list object? Pin
Pete O'Hanlon26-May-11 5:50
mvePete O'Hanlon26-May-11 5:50 
AnswerRe: How to combine 3 different list objects into a single list object? [modified] Pin
Luc Pattyn26-May-11 6:18
sitebuilderLuc Pattyn26-May-11 6:18 
Even when your SalesTeamXyz classes would inherit from a common SalesTeam class, you wouldn't be able to simply cast a List<SalesTeamNorth> to a List<SalesTeam>, so the three lists have no common ancestor. [fixed angular brackets here].

Now do you really want those three classes? and even if you do, do you need the highly specialized lists? it would probably make more sense to have compatible lists, like so:
List<SalesTeam> teamNorth;
List<SalesTeam> teamSouth;
List<SalesTeam> teamEast;

while you still can store more specialized teams in them (with a risk of making some mistakes).

Here is a complete example:
class SalesTeam {
	public string name;
}
class SalesTeamNorth : SalesTeam {
	public SalesTeamNorth(int v) { name="N"+v; }
}
class SalesTeamSouth : SalesTeam {
	public SalesTeamSouth(int v) { name="S"+v; }
}
public override void Test(int arg) {
	List<SalesTeam> teamsNorth=new List<SalesTeam>();
	for(int i=0; i<3; i++) teamsNorth.Add(new SalesTeamNorth(i));
	List<SalesTeam> teamsSouth=new List<SalesTeam>();
	for (int i=0; i<3; i++) teamsSouth.Add(new SalesTeamSouth(i));
	
	// now iterate all teams
	foreach (List<SalesTeam> teams in new List<List<SalesTeam>>(){ teamsNorth, teamsSouth }) {
		foreach (SalesTeam team in teams) {
			log(team.name);
		}
	}
}


Smile | :)
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Please use <PRE> tags for code snippets, they improve readability.
CP Vanity has been updated to V2.3
modified on Thursday, May 26, 2011 12:43 PM

AnswerRe: How to combine 3 different list objects into a single list object? Pin
SledgeHammer0126-May-11 6:21
SledgeHammer0126-May-11 6:21 
AnswerRe: How to combine 3 different list objects into a single list object? Pin
dasblinkenlight26-May-11 6:35
dasblinkenlight26-May-11 6:35 
GeneralRe: How to combine 3 different list objects into a single list object? Pin
Sanjay J Patolia27-May-11 1:09
Sanjay J Patolia27-May-11 1:09 
AnswerRe: How to combine 3 different list objects into a single list object? Pin
V.26-May-11 23:27
professionalV.26-May-11 23:27 
AnswerRe: How to combine 3 different list objects into a single list object? Pin
BobJanova26-May-11 23:42
BobJanova26-May-11 23:42 
Question(Outlook 2007 add-ins) custom attach file button [modified] Pin
kharisma16526-May-11 3:43
kharisma16526-May-11 3:43 
QuestionProblem when starting Windows Phone 7 Emulator Pin
nstk26-May-11 2:04
nstk26-May-11 2:04 
AnswerRe: Problem when starting Windows Phone 7 Emulator Pin
Not Active26-May-11 2:30
mentorNot Active26-May-11 2:30 
GeneralRe: Problem when starting Windows Phone 7 Emulator Pin
nstk26-May-11 5:04
nstk26-May-11 5:04 
GeneralRe: Problem when starting Windows Phone 7 Emulator Pin
Not Active26-May-11 5:14
mentorNot Active26-May-11 5:14 
GeneralRe: Problem when starting Windows Phone 7 Emulator Pin
nstk26-May-11 6:22
nstk26-May-11 6:22 
GeneralRe: Problem when starting Windows Phone 7 Emulator Pin
Mark Salsbery26-May-11 11:04
Mark Salsbery26-May-11 11:04 
GeneralRe: Problem when starting Windows Phone 7 Emulator [modified] Pin
nstk27-May-11 1:33
nstk27-May-11 1:33 
GeneralRe: Problem when starting Windows Phone 7 Emulator Pin
Mark Salsbery27-May-11 9:14
Mark Salsbery27-May-11 9:14 
GeneralRe: Problem when starting Windows Phone 7 Emulator Pin
nstk28-May-11 3:09
nstk28-May-11 3:09 
GeneralRe: Problem when starting Windows Phone 7 Emulator Pin
Mark Salsbery28-May-11 5:42
Mark Salsbery28-May-11 5:42 
GeneralRe: Problem when starting Windows Phone 7 Emulator Pin
nstk28-May-11 21:41
nstk28-May-11 21:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.