[Mono-list] bool function passing parameter problem

Stifu stifu at free.fr
Wed Jun 9 16:11:27 EDT 2010


2 solutions:

1- Make the stuff class static, so you don't need to create a stuff object.
Code:
static class stuff

2- Create a stuff object before calling the method.
Code:
stuff myStuff = new stuff();
test = myStuff.calc1(val1,val2,val3);


Solaris wrote:
> 
> Hi i am a beginner on c#,i have trouble as per-topic,it returns error :
> 
> `Test.calculate.validation.Val(string, string, string)': An object
> reference is required for the nonstatic field, method or property (CS0120) 
> 
> The code :
> using System;
> using System.Collections.Generic;
> using System.Text;
> using System.Security.Cryptography;
> using Boo.Lang.Runtime;
> namespace Test
> {
>     namespace calculate
>     {
>         class stuff
>         {
>             public bool calc1(string num1, string num2, string num3)
>             {
>                 ....
>                 return true;
>             }
>         }
>         class MainClass
>         {
>             public static void Main (string[] args)
>             {
>                 string val1 = "name";
>                 string val2 = "address";
>                 string val3 = "44";
>                 bool test;
>                 test = calculate.stuff.calc1(val1,val2,val3);
>                 Console.WriteLine (test);
>             }
>         }
>     }
> 
> using mono 1.2.5,i cann't upgrade since my school only allowed using this
> runtime :(.
> 

-- 
View this message in context: http://mono.1490590.n4.nabble.com/bool-function-passing-parameter-problem-tp2249436p2249451.html
Sent from the Mono - General mailing list archive at Nabble.com.


More information about the Mono-list mailing list