|
As far as I know, there isn't an equivalent exception. If you need an exception of this specific type, you will need to derive it yourself from ApplicationException.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
just use ApplicationException as you are just advised
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
I want to process something when keys.control and keys.left are pressed at the same time,so how do i know if them are pressed at the same time? Thanks!(C#)
|
|
|
|
|
Detect when the control key is pressed and released and store the status in a variable, so that when the left key gets pressed you can check if the control key is currently pressed.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks for you reply!
I have solve my question.
code:
//Onkeydown
if(e.KeysData.tostring().contains("Control")&&(e.Keysdata.tostring().contains("Left"))
{
// do my work;
}
But i found a erratic thing:
if i press keys.left or Right/up/down,it ignore me in function OnKeyDown,OnKeyUp,OnKeyPress;
if i press keys.control and keys.left,it will process my work;
if i press keys.shift and keys.left,it will ignore me in function OnKeyDown,but process in OnkeyUp;
.....
i want to know when will those events occur?Could you help me?
|
|
|
|
|
Hi,
you can get the instantaneous value of the modifier keys using Control.ModifierKeys
so you don't have to track those keys yourself (which you can hardly do correct, say e.g.
the CTRL key gets pushed down on one Control, then released above another Form).
BTW: don't convert to string for a logical test; instead of
if(e.KeysData.tostring().contains("Control"))...
you can do:
if ((e.KeysData & Keys.Control)==Keys.Control)...
or
if ((e.KeysData & Keys.Control)!=0)...
|
|
|
|
|
Hi All,
I'm just looking at my class that builds a dynamic filter to be apply to a DataView. Originally the potential input to this class was predefined a ComboBox for this field, one for this field etc ...
However, I'm now looking at adding in some more complexity which may include an unknown number of certain ComboBoxes for a particular field. This is obviously adding in a lot of complexity to building the required filter string.
Is there a design pattern for this that I should be reading up on to make this class extendible and very dynamic??
Thanks in advance,
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
Hi I was wondering how can I select specific row in dataGrid.
I want that if textbox (value) matches with sepcific cell in datagrid than i want to select this row.
Can you help me ?
|
|
|
|
|
if("dd"==DataGrid.items(i).cells(j).text)
so what you want may be:
DataGrid.items(i).cells(j).RowNumber(this is the row index in the control)
|
|
|
|
|
See the Following Article
http://www.codeproject.com/KB/cs/N-Tier22.aspx[^]
Hope it helps
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
hi,
what is the advantages of switch over the if/else ?
where we prefer the if/else over the switch?
|
|
|
|
|
Switches are generally easer to read for a large number of conditions or a set of conditions that could possibly change over the lifetime of the product. If/else is great when you have a small (2-3, in my opinion) number of conditions.
That being said, there are times when you still have to use an if/else (or if/else if/else) block with a large number of conditions as switches only let you switch on a limited set of data types.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
In addition to the above, with some data, a switch statement will resolve into a simple jump table. A switch statement with strings may end up using a hash table, increasing performance.
Even for simple compares, I tend to use if/else if the number of elements is one or two items.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Anywhere you compare the same expression to several values, you can use a switch instead.
If you have a lot of comparisons, a switch usually gives clearer code, and may perform a bit better. If you only have two-three comparisons, it's mostly a matter of taste. Use whatever best fits the intention of the code.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Guffa wrote: Anywhere you compare the same expression to several values, you can use a switch instead.
As long as they are simple integers, or strings; and literal!
|
|
|
|
|
If you have a very large number of possible values to test for, you can order nested if/else structures to simulate a binary search.
For the innermost loop of time-critical code, this can run faster than a switch that tests each value sequentially.
For example if value is between 0 and 7:
if (value < 4)
if (value < 2)
if (value == 0)
else
else
if (value == 2)
else
else
This will find the value in three steps, as opposed to up to seven steps using a sequential method.
|
|
|
|
|
Don't forget that a switch allows you to have a code block that matches several values.
And a goto case isn't quite as maligned at a raw goto .
|
|
|
|
|
Hello everyone,
New to Web Services. After some experiment, some basic questions.
1. What is the function of a code hehind file? Any benefits of have a separate asmx and asmx.cs file?
2. When we press F5 to debug, I it is not running on IIS. If IIS is not hosting the web services, which party hosts the web services when we use F5 to debug?
3. I am always confused what is the function and why we need [WebService]? I think [WebMethod] is enough since we expose web service through a public function, not through a class (marked with WebService attribute).
thanks in advance,
George
|
|
|
|
|
George_George wrote: 1. What is the function of a code hehind file? Any benefits of have a separate asmx and asmx.cs file?
The code behind file allows you to separate the code from the presentation (UI). You generally want to do this so you can make changes to the logic without affecting the UI and/or allow a graphics designer to work with the UI and not affect the logic.
George_George wrote: 2. When we press F5 to debug, I it is not running on IIS. If IIS is not hosting the web services, which party hosts the web services when we use F5 to debug?
I'm not 100% sure on this, but I believe it will be running on an internal web service that is started by Visual Studio.
George_George wrote: 3. I am always confused what is the function and why we need [WebService]? I think [WebMethod] is enough since we expose web service through a public function, not through a class (marked with WebService attribute).
From MSDN[^]: The WebServiceAttribute is not required for an XML Web service to be published and executed. You can use the WebServiceAttribute to specify a name for the XML Web service that is not restricted by the rules for a common language runtime identifier, which is used in the service description and the Service help page for the XML Web service.
An XML Web service should change its default XML namespace before it is made public. Each XML Web service needs a unique XML namespace to identify it so that client applications can distinguish it from other services on the Web. http://tempuri.org/ is available for XML Web services that are under development, but published XML Web services should use a more permanent namespace.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
Thanks Scott,
1.
For UI, I am confused. Web Service has no UI, right? What do you mean UI here? Graphical User Interface?
2.
For item 3.
In my previous senses, I think a web serivce is a remote method call which takes some parameters and return something, so I think it is similar to a method, so I think a public method described with WebMethod is called a web service. This is why I am confused and asked question 3.
And from your experience, you call a class a web service? If the class has more than one Web Methods, how do you call the methods?
regards,
George
|
|
|
|
|
George_George wrote: For UI, I am confused. Web Service has no UI, right? What do you mean UI here? Graphical User Interface?
Ahhh...yes, web serivces have no UI. (Yes, UI == Graphical User Interface.) However, my statement about the purpose of a code behind (in general) still holds true. The asmx is the service equivalent to the aspx file. Best practice should still be to put the code in the code behind file.
George_George wrote: In my previous senses, I think a web serivce is a remote method call which takes some parameters and return something, so I think it is similar to a method, so I think a public method described with WebMethod is called a web service. This is why I am confused and asked question 3.
You are almost correct. A web service method is a remote method call which takes some parameters and return something. A web service is a collection of web service methods.
George_George wrote: And from your experience, you call a class a web service? If the class has more than one Web Methods, how do you call the methods?
Yes, a class would be called a web service. If it has more than one web method, you still call them the same way as if it only had a single web method.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
Cool Scott!
Yes, we always edit asmx.cs file for implementation for detailed logics for web services. But what the benefit or benefits will we have if we separate a couple of lines of XML document in asmx and source codes in asmx.cs file? Could you show me a sample to show the benefits please?
regards,
George
|
|
|
|
|
Can't really show any concrete (or probably even any abstract) examples that show the benefits for web services. Anything else, I think the benefits are trivially clear (separation of concerns is almost always a good thing).
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
Thanks Scott,
I understand the general point of design separation (or loosely coupled), but what specific points do you mean separation here?
regards,
George
|
|
|
|
|
George_George wrote: but what specific points do you mean separation here?
I'm not sure I can give you specifics. If you already understand the benefits of separating the UI logic from the back-end logic, you have what you need. As I said, there are probably less reasons for doing this in a web service other than following best practices and making maintenance a bit easier.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|