Click here to Skip to main content
15,922,166 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have written this code


MSIL
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions ;

namespace bank
{
    class account
    {
        private float balance;
        public void Deposite(float amount)
        {
            balance+=amount;
        }
        public void withdraw(float amount)
        {
            balance-=amount;
        }
        public void TransferFunds(account destination, float amount)
        {
        }
        public float Balance
        {
            get
            {
                return balance;
            }
        }
        public static void testmethod()// from here i am writing testcode which i want to run in Nunit but in this Assert.AreEqual is also not supporting   
        {
            account a1 = new account();
            a1.Deposite(200.00f);
            account a2 = new account();
            a2.Deposite(15.00f);
            a1.TransferFunds(a2, 100.00f);
            account.Equals(250.00f, a2.balance);
            account.Equals(100.00f, a1.balance);
        }
    }
}



I am getting this error

Error 1 Program 'C:\Test Project\ConsoleApplication2\ConsoleApplication2\obj\Debug\ConsoleApplication2.exe' does not contain a static 'Main' method suitable for an entry point ConsoleApplication2
Posted

You are compiling your code to produce an exe file, then an entry point is needed, i.e. a method from which the execution of your application starts.
If you want to build an executable file that only holds classes to be used by other applications, you should use a library project, that produces a dll as output.
 
Share this answer
 
Main() method is the method from where code execution starts.
Your console application doesn't contain one.

Either rename testmethod() to Main().
Or, if you need the testmethod, Create a new static method called Main() and call testMethod() inside it.
 
Share this answer
 
Use the following code. it will resolve the problem:

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions ;

namespace bank
{
    class account
    {
        private float balance;

        public void Deposite(float amount)
        {
            balance += amount;
        }
        public void withdraw(float amount)
        {
            balance -= amount;
        }
        public void TransferFunds(account destination, float amount)
        {
        }
        public float Balance
        {
            get
            {
                return balance;
            }
        }
        public static void Main
        {
            account a1 = new account();
            a1.Deposite(200.00f);
            account a2 = new account();
            a2.Deposite(15.00f);
            a1.TransferFunds(a2, 100.00f);
            account.Equals(250.00f, a2.balance);
            account.Equals(100.00f, a1.balance);
        }
    }
}
 
Share this answer
 
v2
Add Main method in your code as follow

public static void main()
{
testmethod();
}



Try it!!!!!!!!!!
 
Share this answer
 
Comments
Sandeep Mewara 1-Oct-10 12:00pm    
Can you please explain it? :doh:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900