|
Except if the exception occurs during execution of the finally-block...
|
|
|
|
|
My memory may not be correct, but I seem to recall a time in C++ when try-finally was a macro and try-catch a language intrinsic, so you couldn't mix them together. If you wanted to do both, you pretty much had to code it up that way. Maybe I recall wrong though?
Unless there's more code inside the try-catch that isn't inside the try-finally, it doesn't make much sense to code it that way.
patbob
|
|
|
|
|
It is legal but personally,
I prefer
try
{
}
catch (IOException e)
{
}
catch(MyException e)
{
}
.
.
.
.
.
.
catch (Exception e){
}
|
|
|
|
|
That's a do-while.
|
|
|
|
|
How to load Data From SQL databse
|
|
|
|
|
|
|
Hi!
I am making Linqtosql application in which classes are used in mapping of database.
I want to let the user input the class name from interface(windows form)
for e.g
if
Class name = hello
its object declaration is
e.g
hello object = new hello()
now in this I want the user to enter the class name "hello"
i tried storing user input in a string , but doesnt work , what to do?
|
|
|
|
|
Use reflections in C# with reflections u can store the class name in a string and then create the object of that class at run time Click Here
modified on Wednesday, May 4, 2011 1:48 AM
|
|
|
|
|
I couldn't understand the tutorial..
plz just in simple explanation , tell that how can i store a class name in string format?
I have a class let say ABC
let say it has fields.
class abc
{
int a;
int b;
}
now if i want to make an object of abc in an another class, through user entering the class name , how to do using reflections?
I am sure it is just 2 lines of code
|
|
|
|
|
Type type = Type.GetType("abc");
object obj = Activator.CreateInstance(type);
pass the class name in the GetType function if the class has a namespace pass it with the namespace.classname
rate me if this post was helpful
modified on Monday, May 9, 2011 6:51 AM
|
|
|
|
|
i tried it.
I had the namespace FYP_RFID and class name RECORDS.
Type type = Type.GetType("FYP_RFID.RECORDS");
object obj = Activator.CreateInstance(type);
BUT when i try to acces any member uding obj.
nothing happens
but when i manually make the object like
RECORDS OBJ = NEW RECORDS();
THEN through obj. function i can acess the members of class. what could be the problem?
(I appreciate you helping me out )
|
|
|
|
|
There is a class called MethodInfo where in you will get all the info of the methods in the object and i would suggest you to learn this from any forums because it would help you more to learn about it like we could only guide you how to do a particular thing it would be good for you to learn new things
|
|
|
|
|
I have 2 SplitContainers(splitContainer1 and splitContainer2) in the WinForm. Both orientation is Horizontal, Dock is Fill. splitContainer2 in the panel1 of splitContainer1 .
When panel2 of splitContainer1 cover of the panel2 of splitContainer2, splitContainer2 is not resize.
why? how to do? thanks. And I want the panel1 of splitContainer1 is not fixe.
|
|
|
|
|
I'm slightly confused about the way the problem is explained and presented.
I get the first bit : You have two splitcontainers, each horizontally orientated and you've put Split2 in Panel 1 of Split1.
The second bit is what confuses me. Could you please refraise that sentence for me. I'm not sure what you're trying to achieve.
|
|
|
|
|
Drag Split1's Splitter. Display only one panel of the Split2.
If Split1's resize event fire in this time, Split2 not resize.
why do the split2 not resize?
how to solve?
But I dont want to fixed size of the panel of the Split1 which contains split2.
|
|
|
|
|
Hi all,
In my c# application i.e., windows application i am using a combobox and in its collection properties i have added some data.
When ever i run my application in combobox it doesn't show any default value,its shown empty until it is selected.
How can i shown default value in combobox in windows application ?
Thanks in advance.
|
|
|
|
|
In the designer, you can set comboBox1.Text = "First Item"; or you simply display the first item in your collection in the e.g. form load event.
|
|
|
|
|
Use combobox SelectedIndex to select the default value in the combobox
|
|
|
|
|
When you're application loads, or when the combobox is filled, use this :
comboBox.SelectedIndex = 0;
|
|
|
|
|
The two answers above me are correct in different cases. If the DropDownStyle is DropDown (i.e. drop/edit), set the Text property to have an initial value. If it is DropDownList, set SelectedIndex (or SelectedItem). You should do this after InitialiseComponent is called; I typically do it lower down in the form class constructor.
Alternatively, if you data bind the combos, they will initialise to the initial value of the property to which they are bound.
|
|
|
|
|
this code may help you..
private void loadComboBox()
{
if (this.cmb.DataSource == null)
{
this.cmb.Items.Add("Please Wait");
this.cmb.Text = "Please Wait";
this.cmb.Refresh();
}
DataTable tbl = comboData() as DataTable;
tbl.Rows.Add(0, "<Select>");
cmb.DataSource = tbl;
cmb.DisplayMember = "Name";
cmb.ValueMember = "Id";
cmb.SelectedValue = 0;
}
|
|
|
|
|
HI,
I have arraylist and the first item in array represent time , the number of message in array may be reach up to 10,000 messages , so if I have messages reached to 2000 message the message number 20001 is set to 0 and when I try to get the total time I have problem because the total is the final element.
some issues :-
- if message set to zero after number of message I will consider the past time is 3640 seconds and so on.
total time = 3640 + the last element in the last in the next items.
- if number of message not set to zero the end item will represent the total time.
<br />
for (int j = 0; j < numberOfMessagesInSection; j++)<br />
{<br />
<br />
nextValue = int.Parse(MessageTimeAssociation[next + 1].messagebytes[0]);<br />
<br />
if (nextValue >= int.Parse(MessageTimeAssociation[j].messagebytes[0]))<br />
{<br />
totalSectionTime = int.Parse(MessageTimeAssociation[numberOfMessagesInSection - 1].messagebytes[0]);<br />
<br />
}<br />
else<br />
{<br />
<br />
totalSectionTime += 3640;<br />
<br />
}<br />
this my code but my problems appears in this cases :-
if the arraylist contains few messages the total time should be the final element but this code not achieve it.
|
|
|
|
|
This has a bad code smell about it that can be detected from the moon, and that's made of cheese.
Honeyboy_20 wrote: I have problem because the total is the final element.
So don't do that then.
The main problem with this is how you are representing your data: ArrayList has almost zero use since generics came out. You might need a List<Message> or HashSet<Message> or possibly Queue<Message> it depends on what you are doing, even then other collections might be more appropriate. In any case storing multiple object types the way you have described it in an ArrayList is a recipe for disaster, you should:
Create a new class to store your data
Add the appropriate Generic collection as a property (make the property read-only: you can still add items externally)
Add properties to store any timings you need
I don't fully understand your problem, but whatever it is this should provide a start.
|
|
|
|
|
I ask about condition as logical if you can help ok or stop.
|
|
|
|