hey i have a question how do i get my funktion to work in the design.cs?

namespace Visma_projekt
{
    public class BlackJack
    {
        public string[] Cards = new string[51];
        public void SkapaKort()
        {
            System.Console.WriteLine("Ehhhh");
        }      
    }
}

i want to call the funktion from this code visma.cs into the form1 design button

namespace Visma_projekt
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnsubmit_Click(object sender, EventArgs e)
        {
            BlackJack.CreateCards(); 
        }
    }
}

the first code is visma.cs
the secound one is form1.cs
thank you for answers

Recommended Answers

All 2 Replies

Since SkapaKort is not a static method, you'll need to create an object of type BlackJack then call the method through that object, i.e.

BlackJack myObject = new BlackJack();
myObject.SkapaKort();

thank you Momerath works good :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.