woody121
woody121

Reputation: 358

Using c#/Xamarin, how can I call a class function?

I'm 12 hours into using Xamarin, and have a beginner blocker while working on a Xamarin / c# project for iOS 7.

This is how I though the view controller should call kickOff (but it doesnt work):

using iOS;
...
public void ViewDidLoad () {
    base.ViewDidLoad ();
    kickOff ();
}           

exampleClass.cs:

namespace iOS
{
public class foo
{
    public static void kickOff (){
        Console.WriteLine("Success!");
     }
 }

What am I missing? Thanks!

Upvotes: 0

Views: 2311

Answers (1)

Dan Drews
Dan Drews

Reputation: 1976

You never point to the class foo. You need to tell it where to look for the method kickOff()

The following should work:

foo.kickOff();

Note

Your question doesn't say what doens't work, but I'm assuming it's a compiler error about kickOff not being a valid method

Upvotes: 6

Related Questions