|
|
Then the exception should have the message that is passed in to the constructor. Which is as it should be.
|
|
|
|
|
I explained how you do that in the other thread. If you didn't create mutiple threads about the same thing, the confusion would be less.
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
for example in the following code i've set the value to both source and message.but the application shows error for the MEssage property. I need the soution for this.i need to set the value as in the code. how to set that? Kindly tell me?
public class CustomExp : ApplicationException
{
public void cust(String msg)
{
this.Source = "test";
this.Message = "testing";
}
}
babu
|
|
|
|
|
Set the value of message in the constructor, as in the examples given in the other thread you started.
|
|
|
|
|
I explained how you do that in the other thread. If you didn't create mutiple threads about the same thing, the confusion would be less.
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
That won't even compile.
|
|
|
|
|
Sorry,
public override string Message
{
get
{
return "test";
}
}
public override string Source
{
get
{
return "test";
}
}
Martin
|
|
|
|
|
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.
|
|
|
|
|
Hello Guffa,
Isn't Source also ReadOnly (Only get accessor)?
All the best,
Martin
|
|
|
|
|
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.
|
|
|
|
|
Ok, Thats really not my day.
Sorry for asking!
|
|
|
|
|
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
|
|
|
|
|
I already told you how to set the message. Read my previous post.
If you don't understand it, explain what it is that you don't understand.
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
If you don't need to do any manipulation of the message (and this is generally not a good idea), you should set Message by calling the base constructor:
public class Customexp: ApplicationException
{
public Customexp(string message) : base (message) {}
}
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.
|
|
|
|
|
babutkchn wrote: can anyone tell me how to solve this problem.
You set it in the constructor by calling the base constructor.
|
|
|
|
|
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!!!!!
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.
|
|
|
|
|
What do we know? We're only professional developers
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.
|
|
|
|
|
is there any one who can help me in adding smileyes and backgrounds in chat software. . and tell me about including voice in chat s/w (in c#)
|
|
|
|
|
imshimshal wrote: is there any one who can help me in adding smileyes and backgrounds in chat software
They are just simple graphics - You can use the Bitmap class to work with them.
imshimshal wrote: and tell me about including voice in chat s/w (in c#)
Too vague.
|
|
|
|
|
but when u use graphics in chat, the conversation boxes must accept the RTF (Rich Text Format)text, but I face a lot of problems in the manipulation operations on that format.
|
|
|
|
|
abd_o_d wrote: the conversation boxes must accept the RTF (Rich Text Format)text,
Why must it? Why can't it accept something else?
|
|
|
|