|
This is a sample of a similar method I`m trying to use:
private string GetValueFromProperty(PropertyInfo pInfo)
{
return pInfo.GetValue(this, null).ToString();
}
The lines that are commented out are other options I've tried. All of the above gives me the following error: "Object does not match target type"
|
|
|
|
|
But how are you creating your pInfo?
|
|
|
|
|
List<PropertyInfo> properties = new List<PropertyInfo>();
properties.AddRange(someObject.GetType().GetProperties());
var pInfo = properties.Find(prop => prop.Name.Equals("someName"));
This allows me to retrieve the appropriate PropertyInfo object
|
|
|
|
|
And you want to retrieve the values from someObject, so use that in your GetValue call. For instance:
pInfo.GetValue(someObject, null);
|
|
|
|
|
Thanks that's the one thing I didn't try, and it worked
|
|
|
|
|
No problem. It's the commonest problem with it, which was how I guessed at the top.
|
|
|
|
|
5 for correctly guessing the source of the problem before code was posted. The questioner was indeed not passing the object that he wanted to get the property value from.
|
|
|
|
|
Thanks. The psychic filter didn't let me down today
|
|
|
|
|
hi i want use spider in asp.net please help me
|
|
|
|
|
Well, you have the keywords there. Google awaits you with an eagerness that's just a little bit disturbing.
|
|
|
|
|
First you need a fly, it is best to stun the fly by wacking it gently on the head, not to hard as it gets all squishy and spiders don't like squishy flies. Now I suggest you tie the fly with a piece of cotton and dangle him over the monitor, I find blue tacking the cotton to the top best. Wait very patiently an you may get a spider wander by and snap your fly.
BTW remember to turn off your screen saver you don't want the miss the spider when he comes looking for your fly.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
But asp nets are way too heavy for catching spiders. You need web technology for that.
ok, late on Friday....
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Yeah but you should be able to cast your asp net to a web two right out of the box.
Less late on Friday but an early start on the weekend
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Sorry but I must object. Spiders do like flies squishy, but only on the inside. The outside of the fly should remain crisp and crunchy.
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
|
|
|
|
|
Here's a sample in Flash[^]
V.
|
|
|
|
|
Just in case you wondered why you are being down voted: Your question is not very precise, in fact it is unclear and does not even belong in this forum. This is the C# forum and there is a forum explicitely for ASP.NET[^] questions.
Best Regards,
—MRB
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
|
|
|
|
|
We generally try not to introduce bugs in our software, but that's just me, it could work for you.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
hi
how can i multi inherit with interface
please sample
|
|
|
|
|
interface A { }
public class B { }
interface C : B, A
{
}
You can only inherit one class, but you can inherit multiple interfaces. Just always put the class before the interfaces when inheriting it.
|
|
|
|
|
Multiple inheritance is bad, mmkay? We prefer composition[^]
Bastard Programmer from Hell
|
|
|
|
|
Multiple implementation (of interfaces) is fine, though. A class often actually is (the test for whether inheritance is appropriate) several things defined by simple (one aspect, ideally) interfaces, and implementing each of them makes sense. For example some sort of data model class could easily be an INotifyPropertyChanged, an IEnumerable<T>, and also some kind of IDataProvider interface within your own code. Or just look at the declaration of the collection classes in the framework.
|
|
|
|
|
BobJanova wrote: Multiple implementation (of interfaces) is fine, though.
Multiple inheritance isn't even possible. Yes, you can implement multiple interfaces, but please don't use them to create an object that simply "binds" a few objects together; that's when a composition would be preferable.
The question being phrased as it is, I'd guess that he's trying to combine an IEmployee and a IManager.
..thanks for the reminder though
Bastard Programmer from Hell
|
|
|
|
|
What you are talking about isn't multiple inheritance, it's multiple implementation. Take the following interfaces
public interface IMyInterface
{
void DoSomething();
}
public interface IAnotherInterface
{
void DoSomethingElse();
} Now, you have a class that needs to implement both of these. To do these, you add them to the class definition and then you provide an implementation for the interface methods. It looks like this:
There you go - you have now implemented two interfaces in the same class.
<div class="signature"><small><p>Forgive your enemies - it messes with their heads</p>
<p><a href="http://peteohanlon.wordpress.com">My blog</a> | <a href="http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=213147">My articles</a> | <a href="http://peteohanlon.wordpress.com/moxaml-power-toys/">MoXAML PowerToys</a> | <a href="http://www.molosoft.com/">Mole 2010 - debugging made easier</a> - my favourite utility</p></small></div>
|
|
|
|
|
I am fixing a tcp listening application which is accepting messages on a port. Once the message arrives it is sent to a queue using MSMQ. The message is then received from the queue and put into another queue. So it goes like so:
Message arrives > Message is sent to queue (Q1) > Message is received from queue (Q1) > Message is sent to another queue (Q2)
The same application is doing all this. I am not sure why this has been implemented this way.
The idea is to accept messages in format x, convert them to format y and send it to another application.
I understand the above might be unclear but I am still analyzing the code. I am starting to think the implementer did not understand the concept and use of message queues really well. What do you think?
<b>CodingYoshi</b>
<i>Artificial Intelligence is <b>no</b> match for Human Stupidity.</i>
|
|
|
|
|
if there are three operations:
1. receive data
2. convert data
3. transmit data
then I can imagine a lot of situations that would require or want these to happen independently, i.e. on separate threads and/or using asynchronous I/O; and then having queues between 1 and 2, as well as between 2 and 3, seems logical.
OTOH if nothing is happening in between "Message is received from queue (Q1)" and "Message is sent to another queue (Q2)", then I would doubt that is the most logical and efficient approach.
|
|
|
|