🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.pl.comp.lang.csharp
Article #22261

problem z generic

#22261
From: news.icpnet.pl
Date: Mon, 24 Oct 2011 09:44
59 lines
2282 bytes
Napisałem sobie taką klasę i mam problem:

W programie wartości są niby ok. Jednak na podglądzie zawartości klasy, 
w debugu dostaję te błędy których nie wiem jak usunąć. Czy ktoś mógłby 
wspomóc mnie wiedzą i pomógł rozwiązać problem?


//Min = <error: an exception of type: System::TypeLoadException^ occurred>
//Max = <error: an exception of type: System::TypeLoadException^ occurred>

/////////////////////////////////////////////////////////////////////////////
generic <typename T> public ref class MinMax : public IComparer
{
private:
	T min;
	T max;
	bool start;

	virtual int Compare(Object^ x, Object^ y) sealed = IComparer::Compare
	{
		return((gcnew CaseInsensitiveComparer)->Compare(x, y));
	}
public:
	MinMax()
	{
		start = false;
	}
	property T Add	
	{	
		Void set(T value)
		{
			if(this->start)
			{	
				this->min = (Compare(value, this->min) < 0) ? value : this->min;
				this->max = (Compare(value, this->max) > 0) ? value : this->max;	
			}
			else
			{
				this->min = this->max = value;
				this->start = true;
			}	
		}
	}
	property T Min		{	T get()		{	return this->min;	}	}
	property T Max		{	T get()		{	return this->max;	}	}
	
	Void Clear()
	{
		if(this->start)
		{
			this->start = false;
			this->min = safe_cast<T>(System::Activator::CreateInstance(T::typeid));
			this->max = safe_cast<T>(System::Activator::CreateInstance(T::typeid));
		}
	}
};
//////////////////////////////////////////////////////////////////////////////
Pozdrawiam
S.Z.
Technical Details
Message-ID: <j83c13$du4$1@news.icpnet.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.icpnet.pl!.POSTED!not-for-mail

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.icpnet.pl!.POSTED!not-for-mail
From: "news.icpnet.pl" <zeus@cbk.poznan.pl>
Newsgroups: alt.pl.comp.lang.csharp
Subject: problem z generic
Date: Mon, 24 Oct 2011 11:44:02 +0200
Organization: ICP News Server
Lines: 59
Message-ID: <j83c13$du4$1@news.icpnet.pl>
NNTP-Posting-Host: d157-43.icpnet.pl
Mime-Version: 1.0
X-Trace: news.icpnet.pl 1319449443 14276 109.173.157.43 (24 Oct 2011 09:44:03 GMT)
X-Complaints-To: abuse@icpnet.pl
NNTP-Posting-Date: Mon, 24 Oct 2011 09:44:03 +0000 (UTC)
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:7.0) Gecko/20110922 Thunderbird/7.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit