|
The C# compiler is able to determine that any code after the return statement is unreachable, so execution could never fall through. If you add the break statements after the return statements, you'll see unreachable code warnings when you compile.
From the C# language reference:
The statement list of a switch section typically ends in a break, goto case, or goto default statement, but any construct that renders the end point of the statement list unreachable is permitted. For example, a while statement controlled by the Boolean expression true is known to never reach its end point. Likewise, a throw or return statement always transfers control elsewhere and never reaches its end point.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Hi Richard,
Pl. see here:
switch (x)
{
case 1:
x =4;
break;
case 2:
case 3:
x = 5;
break;
default:
Console.Write("dog");
}
The compiler reports
C:\deepak\test.cs(31): Control cannot fall through from one case label ('default:') to another
What is the actual cause?
Deepak Kumar Vasudevan
http://deepak.portland.co.uk/
|
|
|
|
|
The end-point of your default case is reachable, since it doesn't end with a jump statement (break, return, goto, etc.)
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Does anybody know how to show the childs as tabbed documents in an MDI application?
Thanks
|
|
|
|
|
|
Hi,
Does anybody know how to make a MDI child dock (or a control from a windows control library) and slide like the toolbox?
Thanks
|
|
|
|
|
|
Newbie Simple question, I can change a textbox ForeColor, BackColor so that say the text is Blue,
But how do I do the same to the datetimepicker?
Although the properties are hidden, they can be changed but they make no difference to the form.
Thanks
Steve Graham
|
|
|
|
|
Are there "set" properties for the DateTimePicker ? If not, I don't think it's going to work.
R.Bischoff | C++
.NET, Kommst du mit?
|
|
|
|
|
I need to build a user control base class for a very large application. I must build a User Control base class, so it can be reused in embedded HTML pages and in .NET Win Forms. I need a set of common classes that will house common functionality for the application (e.g. securityUtilities, xmlUtilities, errorUtilities). Can anyone tell me a good method of doing this?
I have run into a few problems:
1) I can't do multiple inheritances in C#.
2) A user control can't be an abstract class.
3) I have considered building interfaces to combine the classes, but I don't need each class to be a static class.
Can anyone help?
Thank you,
Shane
|
|
|
|
|
C# does not support multiple inheritance. You can simulate this through interface inheritance.
R.Bischoff | C++
.NET, Kommst du mit?
|
|
|
|
|
Anonymous wrote:
2) A user control can't be an abstract class.
But why mark it abstract then?
Anonymous wrote:
3) I have considered building interfaces to combine the classes, but I don't need each class to be a static class.
Interfaces works with instance methods and has nothing to do with static classes.
MyDUMeter: a .NET DUMeter clone
|
|
|
|
|
2) A user control can't be an abstract class.
As I understand it, the controls can be abstract but not in the IDE. When you edit the control, the editor creates an instance of a control, which it cannot do if it's abstract.
Depending how complicated your design is, you can set it to not abstract whilst working on it in the editor, and change it to abstract when you have finished editing it.
|
|
|
|
|
Hi!
I have the following problem:
I have two application one of them serializes a class(serialization is OK a can Deserialize it in this app too)
The problem is that when I am trying to Deserialize a class from file using the second application, i am getting FileNotFound error.
What can be wrong?
I am using Binary formmaters.
Looking through the serialized file I found that the name of programm i also serialized and probably that name dont let another program to deserialize the class?
|
|
|
|
|
The problem seems to be finding that file, not the object serialization. Have you written the right location of the file? have you used "\\" (double slash) in the string instead of simply "\", that's a very common error
|
|
|
|
|
No it is not the case, there are two progs, and File not found message is raised during serialization proccess not stream opening, it is also said that he was searching for the program that created that file.
|
|
|
|
|
Hi,
I want to make an app that looks like "Windows Explorer" ( tree view / splitter / my own views).
I have tried with the splitter control, that works fine for a TreeView and ListView, but for my own Windows Forms it doesn't work ( it seems it has to inherit from control).
Is there any way to do that ? How can I use my Windows Forms there, or is there some kind of View class like in the old MFC ?.
Thanks in advance, Greetings
Braulio
|
|
|
|
|
Have you tried placing your control on a Panel?
|
|
|
|
|
Thanks but...
What I want to place inside is not a control, it's WinForm ( I want to have a WinForms, that contains inside two winforms, a tree control, and another form ( that will change, if the user selects another option in the tree).
So I want to have my fix tree control... and 5 differents views..., with MFC I would do it using splitters, and inheriting my windows from the CView class.
Greetings
Braulio
|
|
|
|
|
Hai
I have One .resx file. I have embedded this file into my project.
Assembly thisAssembly = Assembly.GetAssembly(Type.GetType("samp.Form1"));
ResourceManager rmListImages = new ResourceManager("Images1", thisAssembly);
imageList = new ImageList();
imageList.ImageSize = new Size(16, 16);
Bitmap icons = (Bitmap)rmListImages.GetObject("Image");
When I am running the above code it is showing the following error.
An unhandled exception of type 'System.Resources.MissingManifestResourceException' occurred in mscorlib.dll
Additional information: Could not find any resources appropriate for the specified culture (or the neutral culture) in the given assembly. Make sure "Images.resources" was correctly embedded or linked into assembly "samp".
baseName: Images locationInfo: <null> resource file name: Images.resources assembly: samp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Can any body suggest how to solve this.
Chito.
|
|
|
|
|
Hi,
I am using the Microsoft Web Browser control in my c# Windows for. I need to post some data such as password="xxx" in the form when I use the navigate method. I have not yet found a way to use the postData object of this method.
Can anyone shed some light on this?
Thanks
|
|
|
|
|
Hi,
In my C# program, am making dynamic calls to invoke some functions present in a Dll. I am using DefinePInvokeMethod for the same. yet am not getting the results.
Can anyone send an example on how to use this method or give some suggestion.
Thanks
Ranjani
|
|
|
|
|
While we wait for generics, I was wondering about collections for a bit. You see, in the .NET Framework library, it seems that Microsoft has created a nice type-safe collection for pretty much every type they use lists for—AttributeCollection , TreeNodeCollection —you name it, they've got it.
So, for my code, which I'm hoping to turn into a really nice utterly perfect DirectX class library that conforms to all the wonderfulness of all guidelines, should I do this? Right now I'm just using ArrayList s, which work OK. However, I could use Chris Sells's really cool tool[^] CollectionGen to generate a bunch of type-safe collections.
Advice?
-Domenic Denicola- [CPUA 0x1337]
“I was born human. But this was an accident of fate—a condition merely of time and place. I believe it's something we have the power to change…”
|
|
|
|
|
Domenic,
I've used Chris' Sells tool and I liked it. There are also a few good tools at gotdotnet.com in the user examples. Give them a look and see what you think.
"Veni, Vidi, Booyah!" - Ceasar
|
|
|
|
|
I know how to convert an image object into a graphics object by
Graphics g=Image.creatgraphics();
but how to convert a graphics object into an image object?
Or, how do you save the "graph" that you drew into a bmp file?
|
|
|
|