Click here to Skip to main content
15,904,023 members
Home / Discussions / C#
   

C#

 
GeneralRe: DrawImage with NearestNeighbor-Interpolation Pin
Luc Pattyn27-Jun-12 9:47
sitebuilderLuc Pattyn27-Jun-12 9:47 
GeneralRe: DrawImage with NearestNeighbor-Interpolation Pin
LionAM28-Jun-12 5:16
LionAM28-Jun-12 5:16 
Generallocal group to adam group problem Pin
caknoris27-Jun-12 1:38
caknoris27-Jun-12 1:38 
GeneralRe: local group to adam group problem Pin
lukeer27-Jun-12 2:59
lukeer27-Jun-12 2:59 
GeneralHow to make a word in a text modifiable(doubleClick, change color,..) in C# Pin
rongvangso727-Jun-12 0:23
rongvangso727-Jun-12 0:23 
AnswerRe: How to make a word in a text modifiable(doubleClick, change color,..) in C# Pin
Eddy Vluggen27-Jun-12 0:42
professionalEddy Vluggen27-Jun-12 0:42 
GeneralRe: How to make a word in a text modifiable(doubleClick, change color,..) in C# Pin
rongvangso727-Jun-12 5:07
rongvangso727-Jun-12 5:07 
GeneralRe: How to make a word in a text modifiable(doubleClick, change color,..) in C# Pin
Eddy Vluggen27-Jun-12 5:40
professionalEddy Vluggen27-Jun-12 5:40 
QuestionHow to put field at bottom of detail section in Crystal report Pin
maheshk_blr26-Jun-12 21:26
maheshk_blr26-Jun-12 21:26 
Questionmove App.Config to AppData folder Pin
Jassim Rahma26-Jun-12 21:04
Jassim Rahma26-Jun-12 21:04 
AnswerRe: move App.Config to AppData folder Pin
Eddy Vluggen27-Jun-12 0:46
professionalEddy Vluggen27-Jun-12 0:46 
GeneralRe: move App.Config to AppData folder Pin
PIEBALDconsult27-Jun-12 3:09
mvePIEBALDconsult27-Jun-12 3:09 
GeneralRe: move App.Config to AppData folder Pin
Cracked-Down28-Jun-12 0:59
Cracked-Down28-Jun-12 0:59 
QuestionStackOverflowException when pressing a specific button on certain computers Pin
brendanpi26-Jun-12 18:46
brendanpi26-Jun-12 18:46 
AnswerRe: StackOverflowException when pressing a specific button on certain computers Pin
OriginalGriff26-Jun-12 19:22
mveOriginalGriff26-Jun-12 19:22 
GeneralRe: StackOverflowException when pressing a specific button on certain computers Pin
brendanpi26-Jun-12 19:31
brendanpi26-Jun-12 19:31 
SuggestionRe: StackOverflowException when pressing a specific button on certain computers Pin
Trak4Net26-Jun-12 19:54
Trak4Net26-Jun-12 19:54 
GeneralRe: StackOverflowException when pressing a specific button on certain computers Pin
OriginalGriff26-Jun-12 21:08
mveOriginalGriff26-Jun-12 21:08 
AnswerRe: StackOverflowException when pressing a specific button on certain computers Pin
Luc Pattyn27-Jun-12 5:30
sitebuilderLuc Pattyn27-Jun-12 5:30 
GeneralRe: StackOverflowException when pressing a specific button on certain computers Pin
brendanpi27-Jun-12 18:06
brendanpi27-Jun-12 18:06 
AnswerRe: StackOverflowException when pressing a specific button on certain computers Pin
Luc Pattyn27-Jun-12 18:14
sitebuilderLuc Pattyn27-Jun-12 18:14 
QuestionImplementation of Generic Method in List<Class> Pin
ezazazel26-Jun-12 11:16
ezazazel26-Jun-12 11:16 
Hi guys!
I'm dealing with a problem I can't find a solution for. What I'm trying to do is this:
I have a Model which should contain a generic method (generic input and return value).
And furthermore these Models should be merged into a List.
And here it gets complicated and I end up in a dead end.

Here's the code which hopefully makes it more clear:
C#
class MainClass
	{
		public static void Main (string[] args)
		{
			List<ContainerBase> containers = new List<ContainerBase>();
			containers.Add(new ContainerA());
			containers.Add(new ContainerB());

		}
	}

	abstract class ContainerBase
	{
		public string Name {
			get;
			set;
		}

		public abstract TResult Calculate<TResult, TInput>(params TInput[] input);
	}

	class ContainerA : ContainerBase
	{
		#region implemented abstract members of Generics.ContainerBase
		public override TResult Calculate<TResult, TInput> (params TInput[] input) // !! public override double Calculate(params int[] input)
		{
			int[] ints = input as int[];

			double result = 0;
			return result; // !! throws an error
			return result as TResult; // !! doesn't work either
		}
		#endregion
	}

	class ContainerB : ContainerBase
	{
		#region implemented abstract members of Generics.ContainerBase
		public override TResult Calculate<TResult, TInput> (params TInput[] input) // !! public override uint Calculate(params uint[] input)
		{
			throw new System.NotImplementedException ();
		}
		#endregion
	}


This is needed because I want to be able to combine different algorithms (presented by the Model), e.g. Algo 1: combine 3 integers, Algo 2: divide two integers, Algo 3: get the sort via Drag&Drop (in MVVM - hence the unified approach).

An Alternative would be to store a whole Metod in a Property in the Model, but it needs to be generic as well. And I have no idea how to do that either.

Help would be appreciated!
AnswerRe: Implementation of Generic Method in List Pin
Pete O'Hanlon26-Jun-12 11:55
mvePete O'Hanlon26-Jun-12 11:55 
AnswerRe: Implementation of Generic Method in List Pin
Luc Pattyn26-Jun-12 12:09
sitebuilderLuc Pattyn26-Jun-12 12:09 
GeneralRe: Implementation of Generic Method in List Pin
Pete O'Hanlon26-Jun-12 12:26
mvePete O'Hanlon26-Jun-12 12:26 

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.