how to set the value to Exception.Message or this.message properties?
-
Hello babu, This properties are virtual, which you can override in youre class.
public override string Message
{
get "test";
}public override string Source
{
get "test";
}Hope that helps! All the best, Martin
:confused: That won't even compile.
Upcoming Scottish Developers events: * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos
-
Hi all, how to set a value to custom exception message? I tried to set the value, since its a read only property couldnt able to set it...i tried it as follows public class Customexp:ApplicationException { public void frm(String mess) { this.Message="test"; this.Source = "kjashdfkj"; } } for this code, error is as follows Property or indexer 'System.Exception.Message' cannot be assigned to -- it is read only can anyone tell me how to solve this problem. the clear point is, i've to create an exception object and have to set the value for it. Regards babu
babutkchn wrote:
can anyone tell me how to solve this problem.
You set it in the constructor by calling the base constructor.
Upcoming Scottish Developers events: * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos
-
You set the message in the constructor by using the message in the constructor for the base class:
public CustomExp() : base("The message.") {
this.Source = "The source.";
}--- It's amazing to see how much work some people will go through just to avoid a little bit of work.
-
thank you for your kind reply.The this.source is working. i need to set the value to this.message. can you tell me for that babu
-
:confused: That won't even compile.
Upcoming Scottish Developers events: * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos
-
babutkchn wrote:
can anyone tell me how to solve this problem.
You set it in the constructor by calling the base constructor.
Upcoming Scottish Developers events: * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos
Don't you just get sick of saying the same thing over and over again? It's bad enough when it's to different people, but when it's to the same person, arggghhhhh!!!!!:mad:
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before. -
Don't you just get sick of saying the same thing over and over again? It's bad enough when it's to different people, but when it's to the same person, arggghhhhh!!!!!:mad:
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.Pete O`Hanlon wrote:
Don't you just get sick of saying the same thing over and over again? It's bad enough when it's to different people, but when it's to the same person, arggghhhhh!!!!!
Add to that the fact that You, me and Guffa have all told him what to do.
Upcoming Scottish Developers events: * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos
-
Pete O`Hanlon wrote:
Don't you just get sick of saying the same thing over and over again? It's bad enough when it's to different people, but when it's to the same person, arggghhhhh!!!!!
Add to that the fact that You, me and Guffa have all told him what to do.
Upcoming Scottish Developers events: * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos
What do we know? We're only professional developers:-D
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before. -
Martin# wrote:
Isn't Source also ReadOnly (Only get accessor)?
Nope. :) MSDN Library: Exception.Source property[^]
--- It's amazing to see how much work some people will go through just to avoid a little bit of work.