|
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?
|
|
|
|
|
I am talking here about the control itself, there is a control called "RichTextBox" which used for this purpose, but it accept any format of text, but the chat text mainly is a rich text..
|
|
|
|
|
i am created string like "(4000+20(2+2))" is there any math function to excute it and calculete integer value
|
|
|
|
|
The Framework class library doesn't provide this kind of functionality, but probably someone already implemented this or something similar (try google).
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
If one has
<br />
T[] a = new T[](something);<br />
...<br />
Array.Clear(a,0,a.Length);<br />
does Array.Clear use default(T)? The documentation for .NET 2.0 and 3.0 suggests that it doesn't (!):
<br />
public static void Clear(Array array, int index, int length)<br />
Sets a range of elements in the Array to zero, to false, or to a null reference (Nothing in Visual Basic), depending on the element type.
If Array.Clear really does not use default(T), is there some a base class library method that does this:
<br />
static void f(Array a, int index, int length)<br />
{<br />
for (int i = 0; i < a.Length; i++)<br />
{ a[i] = default(T); }<br />
}<br />
where T is the type of the array? Maybe this would be something in System.Collections.Generic in order to allow the method's implementation to get at T. It's easy enough to make my own method to do this but I'd just as soon not do it if something already exists in the base class library.
|
|
|
|