new to sql server

I am building a console app using c# express edition. I'm trying to use a variable's value in a class that is also in another class. The class that it originates in is where the logic and input validation is. I am then trying to pass the variable(or it's value) to another class that contains my database code.This is where I reference it to write the values to the database.

I get an error message that says; 'The name "variable name" does not exist in the current context.' The variables are declared and used in the class where they originate.

I am assuming that I need the other class to inherit the varaible and it's value. I am not sure if inheritance is the correct

way to go about this. Does anyone have any suggestions

.......................................................................................thanks



Re: Visual C# Language inheriting from one class to another?

paoloTheCool

Ok here is the main code:

Code Block

using System;

using System.Collections.Generic;

using System.Text;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

Class1.WriteToSomewhere(Console.ReadLine());

}

}

}

And here is the class1 code:

Code Block

using System;

using System.Collections.Generic;

using System.Text;

namespace ConsoleApplication1

{

class Class1

{

public static void WriteToSomewhere(string readlines)

{

Console.WriteLine("I can write text from another class!!! " + readlines);

}

}

}

If you have any questions, please ask! Smile

Thanks,

paoloTheCool





Re: Visual C# Language inheriting from one class to another?

new to sql server

Thanks for the help. Is that an example of inheritance

I think I need to learn more about objects and encapsulation. Do you know of any good article about this

........................................................thanks again





Re: Visual C# Language inheriting from one class to another?

paoloTheCool

No, this is not an example of inheritance. Here are some links...

http://www.csharphelp.com/archives/archive170.html

http://support.microsoft.com/kb/307205

and this one might be useful too http://www.exforsys.com/tutorials/csharp/inheritance-in-csharp.html

Thanks,

paoloTheCool





Re: Visual C# Language inheriting from one class to another?

Suprotim Agarwal

A simple introduction to objects and encapsulation

http://www.developer.com/net/net/article.php/1435351

HTH,
Suprotim Agarwal

-----
http://www.dotnetcurry.com
-----