|
I'm working with an Infragistics UltraTree. The types loaded into the tree are each stored on the node's Tag property. I want to activate a node based on a particular instance of a type.
So far I have:
public void SelectNodeByEntity<T>(T Entity)
{
UltraTreeNode node = GetNode(UltraTree1.Nodes, Entity);
if (node != null)
{
UltraTree1.ActiveNode = node;
}
}
private UltraTreeNode GetNode<T>(TreeNodesCollection Nodes, T Entity)
{
UltraTreeNode retVal = null;
foreach (UltraTreeNode node in Nodes)
{
var entity = (T)node.Tag;
if (entity == Entity)
{
return node;
}
else
{
if (node.Nodes.Count > 0)
{
return GetNode<T>(node.Nodes, Entity);
}
}
}
return retVal;
}
But it won't compile on the line indicated above with "Operator '==' cannot be applied to operands of type 'T' and 'T'".
How do I pull the object off the tag, convert it to type T and compare it with the type passed in to see if their the same?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
Try using .Equals instead. == isn't allowed when comparing generic types (in the same way as you can't use ++ or --).
|
|
|
|
|
That did it. Thanks Pete!
If it's not broken, fix it until it is
|
|
|
|
|
Not a problem. I'm glad I could help.
|
|
|
|
|
Just the bug left to be corrected now...
(You don't want to terminate the search if the current node is not the entity you're looking for AND it has children, but you are. Instead, if searching the subtree yields null, you want to continue with the next node.)
|
|
|
|
|
... or for a reference equality check,
if((object)entity == (object)Entity){ ... }
|
|
|
|
|
I've never looked into it and I don't have Reflector here - is there any advantage to casting to object and using the equality operator compared to object.ReferenceEquals(a, b) in your opinion?
|
|
|
|
|
I don't think there's any difference, it's a matter of which you find more readable. I like to see == because that can be seen to be an equality check at a glance, whereas a method call you actually have to read the word to find out what is happening.
|
|
|
|
|
i'm working on project related to Data Mining.This project called Medical Data
Analysis, it is a program that analyze medical data, in my case the data is
Breast Cancer Wisconsin. I am using WEKA as my data mining tools and C# as
my front end
and i can't create any thing in this matter
can anyone help me in this
|
|
|
|
|
kimo_4u wrote: can anyone help me in this It's quite possible that they can, but you need to give some more specific details about what problems you are having, it's unlikely that anyone will be able to guess.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
i want to use weka libraries to use some filter and classifications
filter like Replace Missing Values and others?
|
|
|
|
|
Okay, so you have stated what you want to use, but you haven't actually stated any problems here - or shown us any code that you need help with. What, exactly, are you expecting from us?
|
|
|
|
|
as you have said i know what i want to do
but the problem is that i don't How to Do So?
so if anybody might have a little experience can help me ?
thanks
|
|
|
|
|
Well, this[^] tells you what you need to do to set up WEKA with .NET.
This[^] is a handy place to start with WEKA (links to FAQs, etc). Beyond those links, I don't see how we can help you without actually writing your application for you.
|
|
|
|
|
Richard MacCutchan wrote: unlikely that anyone will be able to guess
Or not be in the mood for guessing like I am
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
|
I see the problem. You have a syntax error there.
|
|
|
|
|
..and it needs PRE tags;
dfghfhgfh();
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
It would appear that you have a PEBKAC error going on.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
2 and half years here and you're still not doing anything but testing the keys on your keyboard?
|
|
|
|
|
I think he needs to test other things besides the keys
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
That's in Wales, isn't it?
|
|
|
|
|
Carefull!
Sorry, my fault - I meant "near Caerphilly"
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Hello,
I have a class called LocalSource that accepts a control parameter in it's constructor:
public LocalSource(Control ViewingWindow)
{
this.ViewingWindow = ViewingWindow;
}
The object being passed in has a delegate that accepts a Bitmap:
private delegate void NewFrameDelegate(Bitmap NewFrame);
From my LocalSource class I want to check the passed in control for the NewFrameDelegate, and if it's been assigned call it and pass a Bitmap. Is this possible?
Thanks in advance.
|
|
|
|
|
I don't know if this is what you trying to do, but checking delegates is like for every other object:
if(NewFrameDelegate!=null)
NewFrameDelegate();
No more Mister Nice Guy... >: |
|
|
|
|