No entry point. Program does not contain a suitable 'Main' method [closed] - c#

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CLASSES_2
{
class Building
{
public int Area; // total square footage of building
public int Floors; // number of floors
public int Occupants; // number of occupants
}
class Building_Demo
{
static void main(string[] args)
{
Building house = new Building();
int Area_Per_Person;
house.Area = 4000;
house.Floors = 7;
house.Occupants = 10;
Area_Per_Person = house.Area / house.Occupants;
Console.WriteLine("The house has: \n" + house.Floors + " Floors \n" + house.Occupants + " Occupants"
+ house.Area + "Area \n" + Area_Per_Person + " Area_Per_Person: ");
}
}
}
Can Someone tell me what's wrong with my code? It's telling me that there is no Method suitable for an entry point.
CS5001 Program does not contain a static 'Main' method suitable for an entry point.

Method names are case sensitive. The method should be called Main, with a capital M, not main like you currently have:
static void Main(string[] args)

Related

CS1519 for C# in unity [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I'm new to coding and have encountered an error with the code and I'm unsure how to fix it. I'm using unity 2018 and it tells me -
error CS1519: Invalid token '=' in class, struct, or interface member declaration
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AutoCookies : MonoBehaviour {
public bool CreatingCookie = false;
public static CookieIncrease = 1;
public int InternalIncrease;
void Update() {
InternalIncrease = CookieIncrease;
if (CreatingCookie == false)
{CreatingCookie = true;
StartCoroutine(CreateTheCookie());
}
}
IEnumerator CreateTheCookie ()
{
GlobalCookie.CookieCount += InternalIncrease;
yield return new WaitForSeconds(1);
CreatingCookie = false;
}
}
I've looked at what the error actually means and I've tried to fix it but I've been unsuccessful. The code is designed to auto create cookies for a game I'm coding for my year 12 Major Works.
As Daniel White said, public static CookieIncrease = 1; is the problem.
There is no type definition for CookieIncrease.
public static int CookieIncrease = 1; is probably what you were going for.

I'm a beginner and I can't solve some errors within C# code [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I'm new to C# and I'm currently learning it step by step and I also exercise at every chapter. I'm trying to make a small mad lipz game with what I learned so far but it's not working, something is missing and I think it has to be with the functions.
I'm getting these errors :
CS0103 The name 'color' does not exist in the current context
CS0103 The name 'noun' does not exist in the current context
CS0103 The name 'person' does not exist in the current context
My code:
using System;
namespace Tutorial
{
class Program
{
static void Main(string[] args)
{
Words();
Game();
Console.ReadLine();
}
static void Words()
{
Console.Write(" Write a color: ");
string color = Console.ReadLine();
Console.Write(" Write a noun: ");
string noun = Console.ReadLine();
Console.Write(" Write a person: ");
string person = Console.ReadLine();
}
static void Game()
{
Console.WriteLine("Roses are " + color);
Console.WriteLine( noun + " is dead ");
Console.WriteLine("I should vote " + person);
}
}
}
Thanks a lot!
color, noun and person are local variables in the Words method, and cannot be used outside of it. One way to solve this problem is to declare them as (static) members instead of local variables.
The problem is the scope of the program. The function Words() does not know of the variables, as they are defined in the function Game(). One possible solution would be to add the three variables as parameters to the function Words().
static void Game(string person, string color, string noun) {}

C# - How do I put the Function Regex working? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
Good morning,
I am doing a page for my intership and I found this function but it isn't working, can someone help?
Thank you in advance.
string _id = this.txtIdGrupo.Text;
if (!Regex.IsMatch(_id, #"^\d+$"))
return false;
The output says this:
error CS0103: The name 'Regex' does not exist in the current context
this is not an issue with the bit of code you showed.
This is a namespace issue at the very top of your file.
The solution should be https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/namespaces/
using System;
using System.Text.RegularExpressions;
public class Test
{
public static void Main ()
{
var isNumeric1 = IsNumeric("1");
Console.WriteLine(isNumeric1);
var isNumeric2 = IsNumeric("HelloWorld");
Console.WriteLine(isNumeric2);
//call IsNumeric with the value of this.txtIdGrupo.Text like this
//var isNumeric = IsNumeric(this.txtIdGrupo.Text);
}
private static bool IsNumeric(string str)
{
string id = str;
if (!Regex.IsMatch(id, #"^\d+$"))
return false;
return true;
}
}
See it in action:
https://dotnetfiddle.net/I7cAKs
notice the "using System.Text.RegularExpressions"
Using tools like Resharper and similar will definitely give you hints and will improve your day to day !
Make sure you have the System.Text.RegularExpressions
is imported

How to resolve errors CS1003: Syntax error, '(' expected, and error CS1031: Type expected? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I am creating a 2d platform game in the Unity Engine Version Num - 2018.4.9f1 with c# compiled with Visual Studio Version Num - 1.38.1.
The console in Unity Engine is showing two errors listed below with the code I have in the Visual Studio.
error CS1003: Syntax error, '(' expected
error CS1031: Type expected
My code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
[RequireComponent(typeof)(Text))]
public class CountdownText : MonoBehaviour {
public delegate void CountdownFinished();
public static event CountdownFinished OnCountdownFinished;
Text countdown;
void OnEnable() {
countdown = GetComponent<Text>();
countdown.text = "3";
StartCoroutine("Countdown");
}
IEnumerator Countdown() {
int count = 3;
for (int i = 0; i < count; i++) {
countdown.text = (count - i).ToString();
yield return new WaitForSeconds(1);
}
OnCountdownFinished();
}
}
RequireComponent(typeof)(Text)) is wrong. It should be RequireComponent(typeof(Text))
The typeof operator obtains the System.Type instance for a type.

How to splite Trial c# [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
hi i want to get just the Crm and the number in the line
tenx
string emailsubject = "Email Test 2 CRM:0276002";
public string GetCrmSubjectNum()
{
string final = //;
return "";
}
It is a little bit unclear what you want.
If you always have "CRM" in the subject, then you could do it like following:
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string emailsubject = "Email Test 2 CRM:0276002";
emailsubject = GetCrmSubjectNum(emailsubject);
Console.WriteLine(emailsubject);
Console.Read();
}
public static string GetCrmSubjectNum(string emailsubject)
{
emailsubject = emailsubject.Remove(0, emailsubject.IndexOf("CRM"));
return emailsubject;
}
}
}
I would go with this, because Substring() is the fastest way:
public string GetCrmSubjectNum(string emailSubject)
{
return emailSubject.Substring(emailSubject.IndexOf("CRM:", StringComparison.Ordinal) + "CRM:".Length);
}

Categories