|
Return some value under the try catch should not be a good practices.
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
|
Please Ignore this post
Well.. It depends on how you are using the following code snippets...
public class ReturnExample
{
private String normalExecution()
{
String result = "";
try
{
result = "Entered try block.";
return result;
}
catch(Exception e)
{
result = result + "Entered Catch block.";
return result;
}
finally
{
result = result + "Entered finally block.";
}
}
public static void main(String[] args)
{
ReturnExample example = new ReturnExample();
String result = example.normalExecution();
System.out.println(result);
}
}
Here you will find the reaturing value is updated;
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
Well.. It depends on how you are using it. look at the following code snippets...
public class ReturnExample
{
private String normalExecution()
{
String result = "";
try
{
result = "Entered try block.";
return result;
}
catch(Exception e)
{
result = result + "Entered Catch block.";
return result;
}
finally
{
result = result + "Entered finally block.";
}
}
public static void main(String[] args)
{
ReturnExample example = new ReturnExample();
String result = example.normalExecution();
System.out.println(result);
}
}
Here you will find the reaturing value is updated;
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
Oh, yeah, there is that; but it's easily avoided by not writing that way.
I suppose a better position is simply to avoid return in catch and finally blocks, but allow them in try blocks as long as there are no returns outside the try (the catch must rethrow).
In fact it may be better as an argument for the Single-Return Brigade.
|
|
|
|
|
First you said.
Here you will find the reaturing value is updated;
result = "Entered try block."!
So what's wrong with this?
At next I said try and finally and not try and catch.
And whats the difference between try finally or using?
Both do the same!
Now to your statement "its not a good practice".
Whats wrong with the practice to cleanup everything
you allocated in an function?
Now one question:
Ever seen the limitations of the garbage-collector?
So it can be a good practice to collect the generation
zero (objects with a short lifetime cycle) in a
finally statement, if your objects eats up a large amounts of
memory, or the gc kills your performance!
At last one word to those crying out never catch something till the
exception reaches the gui layer.
This is wrong in general. Its right that you should not catch
everything and send it to nirvana but how about this? (pseudocode)
ConnectionObject con = null;
TransActionObject trans = null;
try
{
con = new ConnectionToSomeDatabase(...);
trans = new TransActionObject(con, ...);
trans.Commit();
trans = null;
}
catch
{
if(trans != null)
trans.Rollback();
throw;
}
finally
{
if(con != null)
con.Close();
}
How to implement something like this?
Whats the point not to use the given possibilities?
If somebody now says, its slow, then you are right
if you use this in a very fast loop, but how about
start a transaction on a database? There is not
comparision!
So just my 2 cent on this.
And yes I will continue make intensive use of this kind of
statements!
Greetings
Covean
|
|
|
|
|
Hi all. Does anyone have any experience deploying a .nunit file to a network share?
I'm trying to share everything involved with running a particular test suite such that anyone on the team can simply access the share, open my nunit file in their NUnit-gui and run to see my status. The test suite that is to be shared is not dependent upon executing any custom code. Every one of the tests is structured similarly to this:
[TestFixture()]
public class CoverageTests
{
[Test()]
public void ReportStatusOfTask1()
{
Assert.IsTrue(false, "Task 1 has not begun yet");
}
[Test()]
public void ReportStatusOfTask2()
{
Assert.IsTrue(true, "Task 2 is ready for review");
}
}
"I need build Skynet. Plz send code"
|
|
|
|
|
Hello Dear Friends,
I've an application which shows the video from the webcam.
I want to create a C# application which can capture the part of the first application that shows the video in it. Can anybody suggest the way to do this. One way to do this is as described below
1) From the first running application that shows the video in it we can get handle of the window and from that window handle we can get the left,top, right,bottom of the area of the application that shows the video. I've HWND of the first running application but how do I get the left,top,height,width of the area which shows the video.
Is there any other way to achieve this or suggestion for this.
Thanks in Advance,
ritz1234
|
|
|
|
|
you need the handle of the control that shows the video or calculate the correct region if you know the correct location of the "videocontrol"..
greetz
|
|
|
|
|
Hi rootjumper,
Thanks for the response.
The problem is that it is the SKYPE which shows the video while we do the video call.And I don't think it use any control for the video so how to get the handle of the region or the location of the video region?
Thanks
ritz1234
|
|
|
|
|
Hi,
I am developing a C# app in which i want to use PIV Middleware but VS didn't accept its dll when i tried to make a reference. I don't have much experience in this type of programming, can some one guide me and refer to some sample codes or articles.
Thanks in Advance
shezi
|
|
|
|
|
Hello,
Could you please explain me how to put icons to the buttons of Windows application? And also I am tryting to put icon to application itself..
All the best
|
|
|
|
|
Message Closed
modified 23-Nov-14 7:17am.
|
|
|
|
|
thank you for the information, one more question what about putting icons instead of buttons?
|
|
|
|
|
I have a ListView control with a column(just for temp. test) and 2 Groups.
Now, the LV getting populated with 10 items(0..9) and associated with first group in ListView. Now when all done, I'm iterating the Items collection. And found it same as appearing in ListView.
http://img40.imageshack.us/i/40225142.png/[^]
private void Form1_Load(object sender, EventArgs e)
{
for (int a = 0; a < 10; a++)
{
ListViewItem lvi = new ListViewItem(a.ToString());
listView1.Items.Add(lvi);
listView1.Groups[0].Items.Add(lvi);
}
}
private void button1_Click(object sender, EventArgs e)
{
richTextBox1.Clear();
for (int a = 0; a < listView1.Items.Count; a++)
{
richTextBox1.Text += listView1.Items[a].Text + "\r\n";
}
}
now, When I set its sort to Descending...it appears like this
http://img39.imageshack.us/i/43854370.png/[^]
In the above screenshot, the indexes are accurate but its showing '9' at the end.
So I thought to add/insert items manually without using inbuilt sorting. And I did but problem persists. Its showing in the sequence the items added/inserted. However the indexes are correct. Any idea guys ?
I also tried ListView.RedrawItems() but nothing seems to works.
Edit : Found something...but View is already set to Details
http://www.codeproject.com/Messages/2509769/Bug-in-ListView-Items-Insert-int-ListViewItem.aspx[^]
Finally Edit 2 :
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=115345[^]
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
modified on Tuesday, November 10, 2009 8:00 AM
|
|
|
|
|
Message Closed
modified 23-Nov-14 7:18am.
|
|
|
|
|
thats not exactly the problem...its a bug
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=115345[^]
anyway, I'll try that guy's method
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Message Closed
modified 23-Nov-14 7:17am.
|
|
|
|
|
I have same
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Good morning.
I was wondering if anyone has come across this anomoly.
I have code to populate a WebBrowser control based on the folder address (e.g. C:\). This code works well and is as follows:
private void cboFolder_SelectedIndexChanged(object sender, EventArgs e)
{
if (cboFolder.SelectedIndex != -1)
{
Cursor.Current = Cursors.WaitCursor;
SetProgressBarMarquee();
lblLoading.Visible = true;
progressBar1.Visible = true;
Application.DoEvents();
this.viewToolStripMenuItem.Enabled = true;
cboSP_Site.SelectedIndex = -1;
cboWS.SelectedIndex = -1;
txtAddress.Text = cboFolder.SelectedValue.ToString();
WebBrowser1.Url = new Uri(cboFolder.SelectedValue.ToString());
}
}
private void WebBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
SetProgressBarContinuous();
lblLoading.Visible = false;
progressBar1.Visible = false;
Cursor.Current = Cursors.Default;
}
I used some code to set up the different folder views from the view menu. Everything seems to work well, but when I try to switch to details, the web browser window go blank until I right click and then it appears. Also periodically, the folder icons will not show up.
Any suggestions? Thank you, WHEELS
modified on Tuesday, November 10, 2009 8:01 AM
|
|
|
|
|
Hi,
I need to create ASP.net application which can convert Office 2007 Word document(*.docx) file to PDF document. Application has constraint as below,
1. Office 2007 is not installed on web server. (Server which is going to host ASP.net application.)
2. Web server will have Window 2003 installed.
3. Web server has Framework 2.0 installed.
Can anyone suggest me how to convert document into PDF with describe limitation.
I appreciate if anyone suggest third party DLL(Paid or Free) which can do that.
Thanks,
Mayur Patel
|
|
|
|
|
|
Thanks Russ.
I will check it.
Mayur Patel
|
|
|
|
|
|