I am new to C#, today I am facing a issue, the mount of "a First Chance Exception" makes my app running extremely slow.
What I did with JAVA style is:
private DateTime convertStringToDateTime(string x)
{
Try
{
DateTime dateX = convert.Datetime(x);
}
catch(FormatException)
{
result null;
}
}
When I run it with debugging, it's keeping throw "a First Chance Exception". I find the solution from one of answers of StackOverFlow. we need try the TryParse
private DateTime convertStringToDateTime(string x)
{
DateTime dateX;
if(DateTime.TryParse(x, out dateX))
{
return dateX;
}
else
{
return null;
}
}
What a good adventure!
Friday, October 10, 2014
Tuesday, November 18, 2008
Reference variable vs. Real object
This example shows what happens for the instance method, static method, variable in the inheritance.
======================== Code ========================
public class Sub extends Super{
int x = 15;
static int y = 25;
public static void main(String args[]){
//super reference and super object
Super t = new Super();
out.println(t.x + " " + t.y);
t.methodOne();
t.methodTwo();
//super reference and sub object
Super ts = new Sub ();
out.println(ts.x + " " + ts.y);
ts.methodOne();
ts.methodTwo();
//sub reference and sub object
Sub s = new Sub();
out.println(s.x + " " + s.y);
s.methodOne();
s.methodTwo();
}
static void methodOne() {out.println("Sub methodOne()");}
void methodTwo() {
out.println("Sub methodTwo()");
methodOne();
}
}
class Super{
int x = 10;
static int y = 20;
static void methodOne() {out.println("Super methodOne()");}
void methodTwo() {
out.println("Super methodTwo()");
methodOne();
}
}
================================================
======================== Answer ========================
10 20
A methodOne()
A methodTwo()
A methodOne()
10 20
A methodOne()
B methodTwo()
B methodOne()
15 25
B methodOne()
B methodTwo()
B methodOne()
================================================
======================== Conclusion ========================
static methods and variables are based on the reference type
Real object type determines which overridden method is used at runtime
================================================
======================== Code ========================
public class Sub extends Super{
int x = 15;
static int y = 25;
public static void main(String args[]){
//super reference and super object
Super t = new Super();
out.println(t.x + " " + t.y);
t.methodOne();
t.methodTwo();
//super reference and sub object
Super ts = new Sub ();
out.println(ts.x + " " + ts.y);
ts.methodOne();
ts.methodTwo();
//sub reference and sub object
Sub s = new Sub();
out.println(s.x + " " + s.y);
s.methodOne();
s.methodTwo();
}
static void methodOne() {out.println("Sub methodOne()");}
void methodTwo() {
out.println("Sub methodTwo()");
methodOne();
}
}
class Super{
int x = 10;
static int y = 20;
static void methodOne() {out.println("Super methodOne()");}
void methodTwo() {
out.println("Super methodTwo()");
methodOne();
}
}
================================================
======================== Answer ========================
10 20
A methodOne()
A methodTwo()
A methodOne()
10 20
A methodOne()
B methodTwo()
B methodOne()
15 25
B methodOne()
B methodTwo()
B methodOne()
================================================
======================== Conclusion ========================
static methods and variables are based on the reference type
Real object type determines which overridden method is used at runtime
================================================
Tuesday, November 11, 2008
SCJP
Those are my study note of the SCJP. I used those notes to prepare the SCJP exam. Wish myself have luck for the exam.
Uploaded on authorSTREAM by maggie.zhou
Uploaded on authorSTREAM by maggie.zhou
Uploaded on authorSTREAM by maggie.zhou
Uploaded on authorSTREAM by maggie.zhou
Uploaded on authorSTREAM by maggie.zhou
Uploaded on authorSTREAM by maggie.zhou
Uploaded on authorSTREAM by maggie.zhou
Uploaded on authorSTREAM by maggie.zhou
Monday, November 10, 2008
SQA
To understand what SQA doing, I create this note. The SQA is not same as quality control, it isn't testing. It is a process control to ensure the quality of software products. Hope my slides can explain the above points with details.
Uploaded on authorSTREAM by maggie.zhou
Uploaded on authorSTREAM by maggie.zhou
Tuesday, October 28, 2008
SQL
One of my study notes about SQL. It covers all the concepts about SQL syntax, database design, query, etc.
Uploaded on authorSTREAM by maggie.zhou
Uploaded on authorSTREAM by maggie.zhou
IPSec
I present the basic concept of IPSec. Let you know about what are differnets between the Transport mode and Tunnel mode, what are differents between ESP and AH, etc.
Uploaded on authorSTREAM by maggie.zhou
Uploaded on authorSTREAM by maggie.zhou
Wednesday, October 8, 2008
Ad hoc Network protocols
This note presents three important Ad hoc network routing protocol. These three protocol are the typical routing types which inspired other protocols. Once you understood these three, you will easily get the key point from others.
Uploaded on authorSTREAM by maggie.zhou
Uploaded on authorSTREAM by maggie.zhou
Subscribe to:
Posts (Atom)