Is the following class declaration valid?

public abstract class BaseItem<TType,TKeyType> : BaseItem

where TType : BaseItem <TType,TKeyType>

Thank you
1990mayurpatelAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

it_saigeDeveloperCommented:
Are you wanting something like this:
using System;

namespace EE_Q28699633
{
	class Program
	{
		static void Main(string[] args)
		{
			ChildItem<string, int> child = new ChildItem<string, int>("Child1", 20);
			Console.WriteLine("Key: {0}; Value: {1}", child.Key, child.Value);
			Console.ReadLine();
		}
	}

	abstract class BaseItem<T, U>
	{
		public T Key { get; private set; }
		public U Value { get; private set; }

		public BaseItem(T key, U value)
		{
			Key = key;
			Value = value;
		}
	}

	class ChildItem<T, U> : BaseItem<T, U>
	{
		public ChildItem(T key, U value) : base(key, value) { ;}
	}
}

Open in new window

Which produces the following output -Capture.JPG-saige-
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
1990mayurpatelAuthor Commented:
I'm assuming so though it doesn't display the output. On your end if you try to include the code I pasted for the question, does it display an error or does it output something? Thank you for taking the time to write the code by the way.
0
it_saigeDeveloperCommented:
My displaying the output has nothing to do with the class declaration.  I displayed output to show that the child object accesses the properties as defined in the base object.

Perhaps I should ask what your end goal is?  What are your specification needs?

-saige-
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

1990mayurpatelAuthor Commented:
Basically the question I was given was set out like this:

Is the following class declaration valid?

public abstract class BaseItem <TType,TKeyType> : BaseItem

where TType : BaseItem <TType,TKeyType>

Open in new window


There is no output of anything. I think it just wants to know if valid.
0
käµfm³d 👽Commented:
When you say things like, "the question I was given...", it makes it sound like a school exam. We are not allowed to give you specific answer to school exams. Is that what this is?
0
1990mayurpatelAuthor Commented:
It is for university but it is a mock quiz. I have figured it out by the way.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.