?

N

nicol

Hi
Plz help me to sole it error

Error 1 The name 'person' does not exist in the current context

using System;

namespace ConsoleApplication120
{
class Program
{
static void Main(string[] args)
{
person(10); // ******** error ******
}
}
class student
{
public int person(int d)
{
return (1);
}
}
}
 
F

Family Tree Mike

Hi
Plz help me to sole it error

Error 1 The name 'person' does not exist in the current context

using System;

namespace ConsoleApplication120
{
class Program
{
static void Main(string[] args)
{
person(10); // ******** error ******
}
}
class student
{
public int person(int d)
{
return (1);
}
}
}

try:

static void Main(string [] args)
{
student Nicol = new student();
int x = Nicole.person(10);
}
 
N

nicol

Hi
Plz help me to sole it error
Error      1       The name 'person' does not exist in the current context
using System;
namespace ConsoleApplication120
{
     class Program
     {
         static void Main(string[] args)
         {
            person(10);  // ******** error ******
         }
     }
     class student
     {
         public int person(int d)
         {
             return (1);
         }
     }
}

try:

static void Main(string [] args)
{
   student Nicol = new student();
   int x = Nicole.person(10);

}

hi Mike thanks of your answer ( it works ) . . .
 
N

nicol

On 5/5/2010 10:47 AM, nicol wrote:
Hi
Plz help me to sole it error
Error      1       The name 'person' does not exist in the current context
using System;
namespace ConsoleApplication120
{
     class Program
     {
         static void Main(string[] args)
         {
            person(10);  // ******** error ******
         }
     }
     class student
     {
         public int person(int d)
         {
             return (1);
         }
     }
}

static void Main(string [] args)
{
   student Nicol = new student();
   int x = Nicole.person(10);

hi Mike thanks of your answer ( it works ) . . .

One else (?)

using System;

namespace ConsoleApplication120
{
class Program
{
static void Main(string[] args)
{
student nicol = new student();
nicol .person(11);
Console.WriteLine(nicol.person(11)); //error
*************
}
}
class student
{
public void person(int d)
{
d = d * 3;
}
}
}

Error 1 The name 'person' does not exist in the current context
 
F

Family Tree Mike

On 5/5/2010 10:47 AM, nicol wrote:
Hi
Plz help me to sole it error
Error 1 The name 'person' does not exist in the current context
using System;
namespace ConsoleApplication120
{
class Program
{
static void Main(string[] args)
{
person(10); // ******** error ******
}
}
class student
{
public int person(int d)
{
return (1);
}
}
}

static void Main(string [] args)
{
student Nicol = new student();
int x = Nicole.person(10);

hi Mike thanks of your answer ( it works ) . . .

One else (?)

using System;

namespace ConsoleApplication120
{
class Program
{
static void Main(string[] args)
{
student nicol = new student();
nicol .person(11);
Console.WriteLine(nicol.person(11)); //error
*************
}
}
class student
{
public void person(int d)
{
d = d * 3;
}
}
}

Error 1 The name 'person' does not exist in the current context

Now your person method is of type void, so it does not return anything.
The results of a void function cannot be written, as it does not
result in anything. Is your intent to write out the results of d * 3,
which may be what your intended return value should be?
 
N

nicol

On May 5, 7:03 pm, Family Tree Mike<[email protected]>
wrote:
On 5/5/2010 10:47 AM, nicol wrote:
Hi
Plz help me to sole it error
Error      1       The name 'person' does not exist in the current context
using System;
namespace ConsoleApplication120
{
      class Program
      {
          static void Main(string[] args)
          {
             person(10);  // ******** error ******
          }
      }
      class student
      {
          public int person(int d)
          {
              return (1);
          }
      }
}
try:
static void Main(string [] args)
{
    student Nicol = new student();
    int x = Nicole.person(10);
}
One else (?)
using System;
namespace ConsoleApplication120
{
     class Program
     {
         static void Main(string[] args)
         {
             student nicol = new student();
             nicol .person(11);
             Console.WriteLine(nicol.person(11));  //error
*************
         }
     }
     class student
     {
         public void person(int d)
         {
             d = d * 3;
         }
     }
}
Error      1       The name 'person' does not exist in the current context

Now your person method is of type void, so it does not return anything.
  The results of a void function cannot be written, as it does not
result in anything.  Is your intent to write out the results of d * 3,
which may be what your intended return value should be?

yes mike i want to show this result ( d*3 ) ----> 33
 
K

Konrad Neitzel

Hi nicol,

nicol wrote on 05.05.10
in microsoft.public.dotnet.languages.csharp

using System;

namespace ConsoleApplication120
{
     class Program
     {
         static void Main(string[] args)
         {
             student nicol = new student();
             Console.WriteLine(nicol.person(11));  //error
         }
     }
     class student
     {
         public int person(int d)
         {
           return d * 3;
         }
     }
}
yes mike i want to show this result ( d*3 ) ----> 33

Just see the changes I did to your code:
1) Removed one unneccessary call in Main(....)
2) Return type of person is now int instead of void.
3) "return" instead of "d = "

And I think I wrote it already in the past: It could be a good idea to
read some introduction to c# or a book. That will explain in detail, how
you can write your code.

The basics abou the stuff, I did:
1) A function has a return type where void means: Nothing will be
returned. If your function has a type other than void, then the function
MUST return such a value.
2) The command "return" can be used to extit a function. If a return type
other then "void" is specified, you have to give the return value, too.

Konrad
 
N

nicol

Hi nicol,

nicol wrote on 05.05.10
in microsoft.public.dotnet.languages.csharp

using System;

namespace ConsoleApplication120
{
     class Program
     {
         static void Main(string[] args)
          {
             student nicol = new student();
             Console.WriteLine(nicol.person(11));  //error
          }
     }
     class student
     {
         public int person(int d)
         {
            return d * 3;
         }
     }

}
yes mike i want to show this result  ( d*3 ) ---->  33

Just see the changes I did to your code:
1) Removed one unneccessary call in Main(....)
2) Return type of person is now int instead of void.
3) "return" instead of "d = "

And I think I wrote it already in the past: It could be a good idea to  
read some introduction to c# or a book. That will explain in detail, how  
you can write your code.

The basics abou the stuff, I did:
1) A function has a return type where void means: Nothing will be  
returned. If your function has a type other than void, then the function  
MUST return such a value.
2) The command "return" can be used to extit a function. If a return type 
other then "void" is specified, you have to give the return value, too.

Konrad

thanks of kornard & mike;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

inheritance problem 2
what is base() in inheritance 2
array of string 3
Indexed class / list 45
small problem 5
Use of event handling 6
interface?! 5
what is the wrong with this implementation of Comparable<T> 4

Top