|
hi,
Navneeth what i was trying to do here is that i need the value of 10 to be returned...
ie we can say
return a;
the value assigned to a is 10...
so that value of a =10 will be returned ans stored inside sum so that we can use it for some other operation.....
am i correct Navneeth......??
also one more doubt in your code u have used a,b and first number and second number .what is the purpose of those.....
ie we have declred x and y as ref variables and are given refrence to a andf b.....
so what is the use of using firstnumber and secondnumber.....
please explain .....
thanks again for comming to my help
C#
|
|
|
|
|
kabutar wrote: also one more doubt in your code u have used a,b and first number and second number .what is the purpose of those.
It was a typing mistake. corrected now.
|
|
|
|
|
Thanks a lot ..........
cheers to you i understood something that i always had difficulty in understanding....
|
|
|
|
|
Welome.
|
|
|
|
|
Awesome work.....Navneeth.....
thanks a lot for helping me out....
thanks a million again
C#
|
|
|
|
|
You call by reference so you can change the parameters within the call. You sample has no benefit using references. A better example would be
public static void Add(int x, int y , ref int result)
{
result = x + y;
}
static void Main(string[] args)
{
int x = 5;
int y = 5;
int result = 0;
Add(x , y , ref result);
Console.WriteLine("{0}", result);
Console.ReadLine();
}
Here, the Add method has no internal members. It uses the pass by value x and y (by value so they can't change) to populate result , passed by reference so it can change. Within the Add signature, the parameters can be called different names....
public static void Add(int firstValue , int secondValue , ref int firstValueAddedToSecondValue)
{
firstValueAddedToSecondValue = firstValue + secondValue;
}
static void Main(string[] args)
{
int x = 5;
int y = 5;
int result = 0;
Add(x , y , ref result);
Console.WriteLine("{0}", result);
Console.ReadLine();
}
The advantage of this method, is you can then use a return value for success or failure of your Add function (if it becomes more complex)
public static bool Add(int x, int y, ref int result)
{
try
{
result = ReallyComplexCalculationDoneBy3rdPartyLib( x , y );
}
catch( Exception e )
{
return false;
}
return true;
}
static void Main(string[] args)
{
int x = 5;
int y = 5;
int result = 0;
bool AddWorked = Add(x , y , ref result);
if (AddWorked)
Console.WriteLine("{0}", result);
else
Console.WriteLine("Addition failed - check log file..etc");
Console.ReadLine();
}
Hope this helps.
"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,
I have OpenOffice.org.Base in my machine, I am new to open office, But I am learing just.
I wanna know how to configure my C# application to OpenOffice's Database.
Thanks,
Prashanth
|
|
|
|
|
I am deploying my product using VSI. In that ther an option to do some action at Installation,Uninstallation. During the Uninstallation of my product i am calling an dll to do some task. There is an option to refere the dll in VSI. But it's asking me for an Entry Point, in my dll i mentiond a entry point as
static void main()
{
System.Diagnostics.Process.Start("NOTEPAD.EXE");
}
and i a, calling this main() as entry point.
After deploying the product, i installed the application and uninstall it for testing, tht dll is not calling/working for me.
Can any one suggest me an link/help how to solve this issue.
Thanks in advance
Know is Drop, Unknown is Ocean
|
|
|
|
|
Exelioindia wrote: entry point for that dll.
Entry point of an application will be main() method. dll is a set of methods/classes. I don't think it needs an entry point.
|
|
|
|
|
hi,
if i have two classes animal(base class) and dog when do we use in the main statement: Animal a1 = new Dog();
because as i undersatnd we create the object of the same class and call methods of different classes after inheritance...ie is Dog a1 = new Dog().....
so how does this statement work:: Animal a1 = new Dog();
can anybody help me
thanks
C#
|
|
|
|
|
kabutar wrote: so how does this statement work:: Animal a1 = new Dog();
Why don't you write a program and experiment this ?
well, see the following code
class Animal
{
public virtual void ShowAnimal()
{
Console.WriteLine("From animal");
}
}
class Dog : Animal
{
public override void ShowAnimal()
{
Console.WriteLine("From dog");
}
}
I am initializing the class as you said
Animal a = new Dog();
a.ShowAnimal();
What will be the output ? This will print "From dog". Your object 'a' looks like Animal , but instantiated with Dog . So obviously it will call the overridden method in Dog class. Now remove the overide keyword in Dog class. It will be like
public void ShowAnimal()
{
Console.WriteLine("From dog");
}
Now run the application and you will find that it called base class function. Because the object looks like Animal , and instance don't have a method that has relation with Animal . Because child method with the same name without keyword oevrride will be considered as a new method. So it will execute base class method.
XMLDocument class having a Save() method which accepts a Stream object. Instead of this, we can pass MemoryStream object which is a child class of stream. So it will call MemoryStream classes methods.
Hope things are clear now. Let me know if it helped
|
|
|
|
|
hi,
thanks navneeth ......
letme conclude tis...
ie we use this method when we have to override am i right.......
hope my conclusion is correct....
thanking you Navneeth
C#
|
|
|
|
|
If you want to override the default functionality of the base class you can use this. If you are removing override keyword from child class, then use new keyword there to avoid compiler warning.
|
|
|
|
|
It also lets you store a collection of 'Animals' in a collection without having to have a collecton of dogs, a collection of cats, a collection of llamas, a collection of...I think you know where I am going.
You can just have a collection of Animals, and add any class dervied from Animal to it.
class Animal {};
class Cat : Animal {};
class Dog : Animal {};
List<Animal>_myListOfAnimals = new List<Animal>();
Animal myCat = new Cat();
Animal myDog = new Dog();
_myListOfAnimals.Add( myCat );
_myListOfAnimals.Add( myDog );
Saying this, if you are using inheritence just to have this ability, then interfaces are the way to go.
"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."
|
|
|
|
|
Hello,
I've spent some time trying to render text or even a control on top of video being played at fullscreen using the AudioVideoPlayback namespace without any luck.
Originally I was aiming to have a transparent control on top of the video, but if I can get text on top, or any control (transparent or not) I'd be happy...
Can someone point me in the right direction? Perhaps provide an example of something similar?
thank you,
khoramdin
|
|
|
|
|
Hi,
you may have a look at ControlPaint class; I haven't used it myself yet, but it holds
some special things that may suit your needs.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hello Im having a problem with trying to parse a html file and extract data and put it in to a XML file.
its creating the xml file but not putting anything in to the file it self.
<code>using System;
using System.Text;
using System.IO;
using System.Xml;
namespace HTMLPARSER
{
class DescribeHtmlContent
{
[STAThread]
static void Main(string[] args)
{
try
{
string temp;
bool htmlFile = false;
StreamReader sStream;
XmlTextWriter xmlWr = new XmlTextWriter(@"C:\Parse\HtmlContents.xml", Encoding.ASCII);
xmlWr.Formatting = Formatting.Indented;
xmlWr.WriteStartDocument();
xmlWr.WriteRaw("\n<?xml:stylesheet type=\"text/xsl\" href=\"StyleSheet.xsl\"?>");
xmlWr.WriteStartElement("describer");
DirectoryInfo dirOne = new DirectoryInfo(args[0]);
FileInfo[] listOfFiles = dirOne.GetFiles();
foreach (FileInfo file in listOfFiles)
{
if (file.Extension.ToLower().Equals(".html") || file.Extension.ToLower().Equals(".htm"))
{
htmlFile = true;
sStream = new StreamReader(file.FullName);
do
{
temp = sStream.ReadLine();
if (temp != null && temp.ToLower().IndexOf("<title>") != -1)
{
int a = temp.ToLower().IndexOf("<title>") + 7;
int b = temp.ToLower().IndexOf("</title>");
temp = temp.Substring(a, b - a);
xmlWr.WriteStartElement("file");
xmlWr.WriteElementString("name", file.Name);
xmlWr.WriteElementString("description", temp);
xmlWr.WriteElementString("path", file.DirectoryName);
xmlWr.WriteEndElement();
xmlWr.Flush();
}
}
while (temp != null);
sStream.Close();
Console.WriteLine("Reading content from file: {0}", file.FullName);
}
}
if (!htmlFile)
Console.WriteLine("No HTML file found in the directory!");
else
{
xmlWr.WriteEndElement();
xmlWr.WriteEndDocument();
xmlWr.Flush();
xmlWr.Close();
}
}
catch (Exception ex)
{
Console.WriteLine("Error: {0}", ex.Message);
}
}
}
}
</code>
Whats up with this?
|
|
|
|
|
Have you checked what value you are getting in temp ?
|
|
|
|
|
Temp is null but my problem i think is i cant even write to the xml file my WriteRaw of the XML file.
|
|
|
|
|
Hi,
I want to position my controls (Rich text box or labels) in my panel dynamically. Is there a way for me to position each controls from left to right without having me to specify the coordinates? The problem is, the output I am having is dependent on a few criteria. So different scenarios will have different sets of label or rich text box for me to display. How can i solve this problem?
Thanks.
|
|
|
|
|
The closest i come across would be the dockstyle but it doesnt automatic shift to the next line when there is no more space in the panel.
|
|
|
|
|
Hi,
I am using infragistics ultrawingrid control.I want to display the totals of a column at the bottom of the grid columns.How can i do that?
Thanks.
Pavan
|
|
|
|
|
Try asking on an Infragistics forum
http://news.infragistics.com/[^]
"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."
|
|
|
|
|
go to
http://forums.infragistics.com
|
|
|
|
|
Hi,
How can I copies a folder with all contents (files And folders in it with all files in subfolders).
File.Copy() only copies files and DirectoriInfi.MoveTo() give me an error that access denied
Best wishes
|
|
|
|