TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Maha
NA
0
324.8k
Compiling but no out put
Jul 4 2013 3:12 PM
This program is given in the following website. It is compiling but not producing any output. Please correct it.
http://www.dotnetperls.com/static-field
using System;
using System.Diagnostics;
class Test1
{
int _a; // Instance fields:
int _b;
int _c;
public void X()
{
this._a++; // Change instance field values:
this._b++;
this._c++;
}
}
class Test2
{
static int _a; // Static fields:
static int _b;
static int _c;
public void X()
{
_a++; // Change static field values:
_b++;
_c++;
}
}
class Program
{
const int _max = 200000000;
static void Main()
{
Test1 test1 = new Test1(); // Instantiate instance fields
Test2 test2 = new Test2(); // Instantiate
var s1 = Stopwatch.StartNew();
for (int i = 0; i < _max; i++)
{
test1.X(); // Instance fields:
test1.X();
test1.X();
test1.X();
test1.X();
}
s1.Stop();
var s2 = Stopwatch.StartNew();
for (int i = 0; i < _max; i++)
{
test2.X(); // Static fields:
test2.X();
test2.X();
test2.X();
test2.X();
}
s2.Stop();
Console.WriteLine(((double)(s1.Elapsed.TotalMilliseconds * 1000 * 1000) / _max).ToString("0.00") + " ns");
Console.WriteLine(((double)(s2.Elapsed.TotalMilliseconds * 1000 * 1000) / _max).ToString("0.00") + " ns");
Console.ReadKey();
}
}
Reply
Answers (
3
)
Merge Multi .xls files into new One Using C#. How ?
DateTime