|
double type makes round by defect. If you wan't round you have to use real...
Visit my blog at http://dotnetforeveryone.blogspot.com
|
|
|
|
|
If it is just the display output you want :-
static void Main(string[] args)
{
double d = 1.0 / 3.0;
Console.WriteLine(d);
Console.WriteLine("{0:0.00}", d);
}</code>
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"This time yesterday, I still had 24 hours to meet the deadline I've just missed today."
|
|
|
|
|
Hi,
Will i be able to use delegates in this code without inheriting the different classes.
If not what is the advantage in using delegates in this code?
Is delegate more useful when we are dealing with multiple forms and events?
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
public delegate void nameofdelegate();
class Program
{
public static void function1()
{
Console.WriteLine("will be called by the delegate");
Console.ReadLine();
}
}
class newprogram:Program
{
public static void function2()
{
Console.WriteLine("second delegate");
Console.ReadLine();
}
}
class mainprogram:newprogram
{
static void Main(string[] args)
{
nameofdelegate delobj = new nameofdelegate(function1);
nameofdelegate delobject = new nameofdelegate(function2);
delobj();
delobject();
}
}
}
Thanking you
k
|
|
|
|
|
new2pgrmg wrote: Will i be able to use delegates in this code without inheriting the different classes.
Yes. You just have to specify the class name to access the methods:
nameofdelegate delobj = new nameofdelegate(Program.function1);<br />
nameofdelegate delobject = new nameofdelegate(newProgram.function2);
---
"Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things."
-- Douglas Adams
|
|
|
|
|
Thank You Sir that was very helpful.
Can you answer these also please
what is the advantage in using delegates in this code?
Is delegate more useful when we are dealing with multiple forms and events
Thanking You
k
|
|
|
|
|
new2pgrmg wrote: what is the advantage in using delegates in this code?
None.
Delegates are used when the method to call is not known when creating the code that will call it, or when the same code will be used to call different methods.
For example, you use a delegate when calling the List<T>.Find method:
List<int> list = new List<int>(new int[] { 1, 2, 3, 4, 5 } );<br />
int firstEven = list.Find(delegate(int x) { return x % 2 == 0; } );
---
"Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things."
-- Douglas Adams
|
|
|
|
|
Hi all,
I want to overwrite an existing file (acttually, it's an excel file). But i don't know whether it's in use or locked by another process or not.
Is there a way to check that.
Thanks.
|
|
|
|
|
use a file which is locked u will get an exception
handle that exception using try catch block ...
Exception handling tat's all
|
|
|
|
|
If you're using the Excel PIAs then the _Workbook class has a ReadOnly property that's useful for determining if the file is a readonly file or if an instance of Excel already has the workbook open. Not sure if it can tell if it's locked by any other process, but it does know if it's locked by Excel.
|
|
|
|
|
Hi
this is my firs post on this board, hope I'll get some help.
I have an wpf application that can run in more then one instance.
I have another web service running in a web page in different app, to invoke method on the already running wpf app.
I can get the wpf processes running that no problem, but can't cast it to instance of an object in order to invoke object public methods.
Is that possible?
thanks in advance
Elad
|
|
|
|
|
Hi all,
I'm developing a simple application in which i need to play AVI with few options
The problems is i'm not getting how to play the avi from some particular frame, like i need to Play from Frame 7, i wont be able to do that but it starts from the initial frame.
Secondly, i need to extract snap to display where the particular subtitle is found. There isnt any function provided to capture the snap, other than invoking our own designed Snapper. Is there any alternate solution.
Hope, anyone among thousands, know such things.
Thanks
Determination and faith are the only keys !
|
|
|
|
|
Hello experts,
I create a desktop application using C#.net 2005. I also set right anchor and dock property of each control. And it works fine on different resolution and while resize the form in XP.
But what I saw the labels are mis-palced in vista. What is the problem...?
Regards
Pankaj Joshi
|
|
|
|
|
Did you ever find a solution to this?
Just found out that i have same issue like you had....
|
|
|
|
|
hello
i need to get different values from different tables but i have to show all in a grid...?
can yu help me?
self confidence+hard work=SUCCESS
|
|
|
|
|
Sorry to say but your question is too confusing. As I interprete it
you want to retrive data from multiple table and want to show in single grid OK?
For that you just write a join query and fill the dataset or datatable and attached it with the grid.
Regards
Pankaj Joshi
|
|
|
|
|
thanks pankaj
self confidence+hard work=SUCCESS
|
|
|
|
|
You just need to write a join query to fetch data... from different tables...
and if u don't want to write a join query and want to fetch data separately from different talbes.. then all the columns and columns type must be same in all the tables from which u want to fetch data
|
|
|
|
|
thanks bhatti
self confidence+hard work=SUCCESS
|
|
|
|
|
with out using join query is ther any possibility?
self confidence+hard work=SUCCESS
|
|
|
|
|
Plz sugest me book or e-book for 3 tier architecture
help as a alias.
Be happy and make others happy.Cheer up...........
|
|
|
|
|
Hey Hey Hey..
So many experts are their so why we need book...?
Regards
Pankaj Joshi
|
|
|
|
|
wat does mean?
help as a alias.
Be happy and make others happy.Cheer up...........
|
|
|
|
|
This means If you have any questions on three tier arch. Feel
free to ask.
Regards
Pankaj Joshi
|
|
|
|
|
i just want to know the basic plz help me or send me any ebook
help as a alias.
Be happy and make others happy.Cheer up...........
|
|
|
|
|
help as a alias wrote: wat does mean?
He is trying to get you to be lazy and not think for your self. He wants to bring you down to his level.
Be independent of thought!
|
|
|
|