Monday, August 27, 2012

C# functions Silverlight

C# functions Silverlight

I have a function in file Code.xaml.cs.

public string send (string url) { //some code... } 

I want to call this function from another .cs file.

send("google.com"); 

But the debugger gives an error! How can I do this?

Answers & Comments...

Answer: 1

Whenever calling a dynamic method from a class, you will have to create an instance of that class.

class Test  {     public string send(string url) {} }  class AnotherClass  {     public AnotherClass()      {         Test t = new Test();         t.send("google.com");     } } 

Otherwise you can simply use the static keyword.

public static string send(..); 
by : Forlan07http://stackoverflow.com/users/392632




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog