naseeam
asked on
Can Visual Studio IDE console application used for creating basic C# object-oriented features ?
The "Introduction to classes" tutorial in following link assumes .NET Core SDK and Visual Studio Core are installed.
https://docs.microsoft.com/en-us/dotnet/csharp/tutorials/intro-to-csharp/index
Is Visual Studio IDE sufficient tool for coding, compiling, and running this tutorial? File - New - Project - Visual C# - Console App (.NET Framework)
https://docs.microsoft.com/en-us/dotnet/csharp/tutorials/intro-to-csharp/index
Is Visual Studio IDE sufficient tool for coding, compiling, and running this tutorial? File - New - Project - Visual C# - Console App (.NET Framework)
I don't see why you wouldn't it be able to run that tutorial using VS 2017 or better.
Visual Studio is a far more powerful IDE than Visual Studio Code and apart from some clear distinctions (listed here: https://code.visualstudio. com/Docs/e ditor/whyv scode). Also, if you like you can use built-in Sandbox to do the entire exercise. Just click on Enter Focus Mode.
Regards,
Chinmay.
Regards,
Chinmay.
ASKER
I'm using Visual Studio Pro 2017
I'm following "Introduction to classes" tutorial at the bottom of following link:
https://docs.microsoft.com/en-us/dotnet/csharp/tutorials/intro-to-csharp/index
.NET Core SDK and Visual Studio Code are not installed in my computer. I want to create, compile, and run this tutorial in Visual Studio IDE.
I copied the code directly from tutorial. Following is the code and compile errors:
Program.cs
BankAccount.cs
Attached are compile errors. Why doesn't it compile?
compile_errors.PNG
I'm following "Introduction to classes" tutorial at the bottom of following link:
https://docs.microsoft.com/en-us/dotnet/csharp/tutorials/intro-to-csharp/index
.NET Core SDK and Visual Studio Code are not installed in my computer. I want to create, compile, and run this tutorial in Visual Studio IDE.
I copied the code directly from tutorial. Following is the code and compile errors:
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace classes
{
class Program
{
static void Main(string[] args)
{
var account = new BankAccount("Amer", 1000);
Console.WriteLine($"Account {account.Number} was created for {account.Owner} with {account.Balance} initial balance.");
}
}
}
BankAccount.cs
using System;
namespace classes
{
public class BankAccount
{
public string Number { get; }
public string Owner { get; set; }
public decimal Balance { get; }
public void MakeDeposit(decimal amount, DateTime date, string note)
{
}
public void MakeWithdrawal(decimal amount, DateTime date, string note)
{
}
}
/* constructor */
public BankAccount(string name, decimal initialBalance)
{
this.Owner = name;
this.Balance = initialBalance;
}
}
Attached are compile errors. Why doesn't it compile?
compile_errors.PNG
Hi Naseeam,
First things first, did you install .Net Core SDK as we discussed in other thread? If yes then you have to select appropriate framework when you create the project. After that things will be straightforward.
Regards,
Chinmay.
First things first, did you install .Net Core SDK as we discussed in other thread? If yes then you have to select appropriate framework when you create the project. After that things will be straightforward.
Regards,
Chinmay.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
.Net Core is not required for that tutorial. It can be used but is not a requirement
ASKER
>> Just click on Enter Focus Mode
Instead, I created "Console App (.NET Framework)" application in Visual Studio IDE. Why doesn't my tutorial program compile?
Regards,
Instead, I created "Console App (.NET Framework)" application in Visual Studio IDE. Why doesn't my tutorial program compile?
Regards,
have you moved your constructor inside the class?
What Eric Said
My Bad... I am way over my head in .Net Core nowadays as it is taking over the world. I did not notice you are doing a .Net Framework stuff. Sorry for the goof up.
a constructor has to be inside a class. move line 20 after 27
My Bad... I am way over my head in .Net Core nowadays as it is taking over the world. I did not notice you are doing a .Net Framework stuff. Sorry for the goof up.
no .Net Core is not required for this specific tutorial. Yes you select the console app
if you want to demystify what .Net Core is, read https://en.wikipedia.org/wiki/.NET_Core
ASKER
Compilation is successful after moving constructor inside the class.
Expert found the root cause and provided working solution.
Expert found the root cause and provided working solution.
from the web site: