Rashmi kaneri

Rashmi kaneri

  • NA
  • 6
  • 5.4k

How to call function and variables declared in other classes

Aug 19 2016 12:32 AM
hi,
i have function stringconcat(a,b) in class1 with namespace s1 and want to call this function in class2.
 
i have written as given below and getting errors like 
Error 1 Cannot declare a variable of static type 's1.class1' 
Error 2 Cannot create an instance of the static class 's1.class1' 
 
Can someone please tell me what is wrong in this code
In file1.cs 
------------- 
namespace s1
{
publis static class class1
public static string a="IN";
public static string b="DIA"; 
public static void stringconcat(a,b);
}
}
In File2.cs 
---------------- 
namespace s1
{
publis static class class2
{
class1 class1=new class1(); 
class1.stringconcat(a,b);
}
}
 
 
 
 
 
 

Answers (3)