教學課程:在 Visual Studio 中建立簡單的 C# 主控台應用程式Tutorial: Create a simple C# console app in Visual Studio

在 C# 的這個教學課程中,您將使用 Visual Studio 建立並執行主控台應用程式,並在這樣做的同時探索 Visual Studio 整合式開發環境 (IDE) 的一些功能。In this tutorial for C#, you'll use Visual Studio to create and run a console app and explore some features of the Visual Studio integrated development environment (IDE) while you do so.

如果您尚未安裝 Visual Studio,請前往 Visual Studio 下載頁面免費進行安裝。If you haven't already installed Visual Studio, go to the Visual Studio downloads page to install it for free.

如果您尚未安裝 Visual Studio,請前往 Visual Studio 下載頁面免費進行安裝。If you haven't already installed Visual Studio, go to the Visual Studio downloads page to install it for free.

建立專案Create a project

首先,我們將建立 C# 應用程式專案。To start, we'll create a C# application project. 在您新增任何項目之前,專案類型會隨附您需要的所有範本檔案!The project type comes with all the template files you'll need, before you've even added anything!

  1. 開啟 Visual Studio 2017。Open Visual Studio 2017.

  2. 從頂端功能表列中,選擇 [檔案] > [新增] > [專案] 。From the top menu bar, choose File > New > Project. (或者按下 CTRL+SHIFT+N)。(Alternatively, press Ctrl+Shift+N).

  3. 在 新增專案 對話方塊的左窗格中,展開 C# ,然後選擇 .NET Core 。In the left pane of the New Project dialog box, expand C#, and then choose .NET Core. 在中間窗格中,選擇 [主控台應用程式 (.NET Core)] 。In the middle pane, choose Console App (.NET Core). 接著,將檔案命名為 CalculatorThen name the file Calculator.

    Visual Studio IDE 的 [新增專案] 對話方塊中的主控台應用程式 (.NET Core) 專案範本

新增工作負載 (選擇性)Add a workload (optional)

如果您看不到 [主控台應用程式] 專案範本,則其取得方式是新增 [.NET Core 跨平台開發] 工作負載。If you don't see the Console App (.NET Core) project template, you can get it by adding the .NET Core cross-platform development workload. 方式如下:Here's how.

選項 1:使用 [新增專案] 對話方塊Option 1: Use the New Project dialog box

  1. 選擇 [新增專案] 對話方塊左窗格中的 [開啟 Visual Studio 安裝程式] 連結。Choose the Open Visual Studio Installer link in the left pane of the New Project dialog box.

    從 [新增專案] 對話方塊選擇 [開啟 Visual Studio 安裝程式] 連結

  2. Visual Studio 安裝程式即會啟動。The Visual Studio Installer launches. 選擇 [.NET Core 跨平台開發] 工作負載,然後選擇 [修改] 。Choose the .NET Core cross-platform development workload, and then choose Modify.

    Visual Studio 安裝程式中的 .NET Core 跨平台開發工作負載

選項 2:使用 [工具] 功能表列Option 2: Use the Tools menu bar

  1. 請取消 [新增專案] 對話方塊,然後從頂端功能表列中選擇 [工具] >[取得工具和功能] 。Cancel out of the New Project dialog box and from the top menu bar, choose Tools > Get Tools and Features.

  2. Visual Studio 安裝程式即會啟動。The Visual Studio Installer launches. 選擇 [.NET Core 跨平台開發] 工作負載,然後選擇 [修改] 。Choose the .NET Core cross-platform development workload, and then choose Modify.

  1. 開啟 Visual Studio 2019。Open Visual Studio 2019.

  2. 在開始視窗中,選擇 [建立新專案] 。On the start window, choose Create a new project.

    檢視 [建立新專案] 視窗

  3. 在 [建立新專案] 視窗的搜尋方塊中輸入或鍵入 ASP.NET 。On the Create a new project window, enter or type console in the search box. 接下來,從語言清單中選擇 C# ,然後從平台清單中選擇 WindowsNext, choose C# from the Language list, and then choose Windows from the Platform list.

    在您套用語言和平台的篩選條件之後,請選擇 [主控台應用程式 (.NET Core)] 範本,然後選擇 [下一步] 。After you apply the language and platform filters, choose the Console App (.NET Core) template, and then choose Next.

    選擇主控台應用程式 (.NET Framework) 的 C# 專案範本

    Note

    如果您未看到 [主控台應用程式 (.NET Core)] 範本,您可以從 [建立新專案] 視窗中安裝。If you do not see the Console App (.NET Core) template, you can install it from the Create a new project window. 在 [找不到您要找的資料嗎?] 訊息中,選擇 [安裝更多工具和功能] 連結。In the Not finding what you're looking for? message, choose the Install more tools and features link.

    [建立新專案] 視窗中 [找不到您要找的資料嗎?] 訊息的 [安裝更多的工具和功能] 連結

    接下來,在 Visual Studio 安裝程式中選擇 .NET Core 跨平台開發工作負載。Then, in the Visual Studio Installer, choose the .NET Core cross-platform development workload.

    Visual Studio 安裝程式中的 .NET Core 跨平台開發工作負載

    接著,選擇Visual Studio 安裝程式中的 [修改] 按鈕。After that, choose the Modify button in the Visual Studio Installer. 系統可能會提示您儲存工作,若收到提示,請依提示執行。You might be prompted to save your work; if so, do so. 接下來,選擇 [繼續] 以安裝工作負載。Next, choose Continue to install the workload. 然後,返回至「建立專案」程序中的步驟 2。Then, return to step 2 in this "Create a project" procedure.

  4. 在 [設定您的新專案] 視窗的 [專案名稱] 方塊中鍵入或輸入 CalculatorIn the Configure your new project window, type or enter Calculator in the Project name box. 接著,選擇 [建立] 。Then, choose Create.

    在 [設定您的新專案] 視窗中,以 'Calculator' 命名您的專案

    Visual Studio 會隨即開啟您的新專案,其中包含預設 "Hello World" 程式碼。Visual Studio opens your new project, which includes default "Hello World" code.

建立應用程式Create the app

首先,我們將探索一些以 C# 撰寫的基本整數運算。First, we'll explore some basic integer math in C#. 然後,我們將新增程式碼來建立基本的計算機。Then, we'll add code to create a basic calculator. 然後,我們會對應用程式進行偵錯以找出錯誤,將其修正。After that, we'll debug the app to find and fix errors. 最後,我們會精簡程式碼,讓其更有效率。And finally, we'll refine the code to make it more efficient.

探索整數運算Explore integer math

讓我們開始使用一些以 C# 撰寫的基本整數運算。Let's start with some basic integer math in C#.

  1. 在程式碼編輯器中,刪除預設 "Hello World" 程式碼。In the code editor, delete the default "Hello World" code.

    從新的計算機應用程式中刪除預設 Hello World 程式碼

    具體來說,刪除 Console.WriteLine("Hello World!"); 一行。Specifically, delete the line that says, Console.WriteLine("Hello World!");.

  2. 鍵入下列程式碼來取代:In its place, type the following code:

            int a = 42;
            int b = 119;
            int c = a + b;
            Console.WriteLine(c);
            Console.ReadKey();
    

    請注意,當您這麼做時,Visual Studio 中的 IntelliSense 功能會提供您自動完成項目的選項。Notice that when you do so, the IntelliSense feature in Visual Studio offers you the option to autocomplete the entry.

    顯示 Visual Studio IDE 中 IntelliSense 自動完成功能的整數數學代碼動畫

  3. 選擇 [Calculator] 來執行您的程式 (或按 F5)。Choose Calculator to run your program, or press F5.

    選擇 [Calculator] 按鈕以從工具列執行應用程式

    主控台視窗會隨即開啟並顯示 42 + 119 的總和,也就是 161A console window opens that reveals the sum of 42 + 119, which is 161.

    顯示整數數學結果的主控台視窗

  4. (選擇性) ,您可以變更運算子來變更結果。(Optional) You can change the operator to change the result. 例如,您可以將 int c = a + b;程式碼行中的 + 運算子變更為 - 進行相減、變更為 * 進行相乘,或變更為 / 進行相除。For example, you can change the + operator in the int c = a + b; line of code to - for subtraction, * for multiplication, or / for division. 在您執行程式時,結果也會變更。Then, when you run the program, the result changes, too.

  5. 關閉主控台視窗。Close the console window.

新增程式碼來建立計算機Add code to create a calculator

讓我們繼續將一組更複雜的計算機程式碼新增至專案。Let's continue by adding a more complex set of calculator code to your project.

  1. 刪除您在程式碼編輯器中看到的所有程式碼。Delete all the code you see in the code editor.

  2. 在程式碼編輯器中輸入或貼上下列新程式碼:Enter or paste the following new code into the code editor:

    using System;
    
    namespace Calculator
    {
        class Program
        {
            static void Main(string[] args)
            {
                // Declare variables and then initialize to zero.
                int num1 = 0; int num2 = 0;
    
                // Display title as the C# console calculator app.
                Console.WriteLine("Console Calculator in C#\r");
                Console.WriteLine("------------------------\n");
    
                // Ask the user to type the first number.
                Console.WriteLine("Type a number, and then press Enter");
                num1 = Convert.ToInt32(Console.ReadLine());
    
                // Ask the user to type the second number.
                Console.WriteLine("Type another number, and then press Enter");
                num2 = Convert.ToInt32(Console.ReadLine());
    
                // Ask the user to choose an option.
                Console.WriteLine("Choose an option from the following list:");
                Console.WriteLine("\ta - Add");
                Console.WriteLine("\ts - Subtract");
                Console.WriteLine("\tm - Multiply");
                Console.WriteLine("\td - Divide");
                Console.Write("Your option? ");
    
                // Use a switch statement to do the math.
                switch (Console.ReadLine())
                {
                    case "a":
                        Console.WriteLine($"Your result: {num1} + {num2} = " + (num1 + num2));
                        break;
                    case "s":
                        Console.WriteLine($"Your result: {num1} - {num2} = " + (num1 - num2));
                        break;
                    case "m":
                        Console.WriteLine($"Your result: {num1} * {num2} = " + (num1 * num2));
                        break;
                    case "d":
                        Console.WriteLine($"Your result: {num1} / {num2} = " + (num1 / num2));
                        break;
                }
                // Wait for the user to respond before closing.
                Console.Write("Press any key to close the Calculator console app...");
                Console.ReadKey();
            }
        }
    }
    
  3. 選擇 [Calculator] 來執行您的程式 (或按 F5)。Choose Calculator to run your program, or press F5.

    選擇 [Calculator] 按鈕以從工具列執行應用程式

    主控台視窗隨即開啟。A console window opens.

  4. 在主控台視窗中檢視您的應用程式,然後遵循提示來新增數字 42119View your app in the console window, and then follow the prompts to add the numbers 42 and 119.

    您的應用程式看起來應該類似下列螢幕擷取畫面:Your app should look similar to the following screenshot:

    主控台視窗顯示計算機應用程式,並包含要採取之動作的提示

將功能新增至計算機Add functionality to the calculator

我們將調校程式碼來新增進一步的功能。Let's tweak the code to add further functionality.

新增小數Add decimals

目前,計算機應用程式會接受並傳回整數。The calculator app currently accepts and returns whole numbers. 但如果我們新增可允許小數的程式碼,會讓其更精確。But, it will be more precise if we add code that allows for decimals.

如下列螢幕擷取畫面所示,如果您執行應用程式,將數字 42 除以數字 119,結果會是 0 (零),並不正確。As in the following screenshot, if you run the app and divide number 42 by the number 119, your result is 0 (zero), which isn't exact.

主控台視窗顯示計算機應用程式不會在結果中傳回小數

讓我們修正程式碼來處理小數。Let's fix the code so that it handles decimals.

  1. Ctrl + F 以開啟 [尋找和取代] 控制項。Press Ctrl + F to open the Find and Replace control.

  2. int 變數的每個執行個體變更為 floatChange each instance of the int variable to float.

    請確認您已在 [尋找和取代] 控制項中切換 [大小寫須相符] (ALT+C) 和 [全字相符] (ALT+W)。Make sure that you toggle Match case (Alt+C) and Match whole word (Alt+W) in the Find and Replace control.

    顯示如何將 int 變數變更為 float 的 [尋找和取代] 控制項動畫

  3. 再次執行您的計算機應用程式,將數字 42 除以數字 119Run your calculator app again and divide the number 42 by the number 119.

    您會看到應用程式現在會傳回小數,而不是零。Notice that the app now returns a decimal numeral instead of zero.

    主控台視窗顯示計算機應用程式現在會在結果中傳回小數

不過,應用程式僅會產生小數結果。However, the app produces only a decimal result. 讓我們進一步調校程式碼,讓應用程式也可以計算小數。Let's make a few more tweaks to the code so that the app can calculate decimals too.

  1. 使用 [尋找和取代] 控制項 (Ctrl + F),將 float 變數的每個執行個體變更為 double,以及將 Convert.ToInt32 方法的每個執行個體變更為 Convert.ToDoubleUse the Find and Replace control (Ctrl + F) to change each instance of the float variable to double, and to change each instance of the Convert.ToInt32 method to Convert.ToDouble.

  2. 執行您的計算機應用程式,將數字 42.5 除以數字 119.75Run your calculator app and divide the number 42.5 by the number 119.75.

    您會看到應用程式現在接受小數值,並會在結果中傳回較長的小數數字。Notice that the app now accepts decimal values and returns a longer decimal numeral as its result.

    主控台視窗顯示計算機應用程式現在接受小數數字並在結果中傳回小數數字

    (我們將在修改程式碼一節中修正小數位數數字。)(We'll fix the number of decimal places in the Revise the code section.)

偵錯應用程式Debug the app

我們已改善基本計算機應用程式,但還不具備處理例外狀況的保險方式,例如使用者輸入錯誤。We've improved on our basic calculator app, but it doesn't yet have fail safes in place to handle exceptions, such as user input errors.

例如,如果您嘗試將數字除以零,或在應用程式僅接受數字字元時輸入英文字元 (反之亦然),則應用程式會停止運作並傳回錯誤。For example, if you try to divide a number by zero, or enter an alpha character when the app expects a numeric character (or vice versa), the app stops working and returns an error.

讓我們逐步解說一些常見的使用者輸入錯誤,在偵錯工具中將其找出,並在程式碼中修正。Let's walk through a few common user input errors, locate them in the debugger, and fix them in the code.

Tip

如需偵錯工具及其運作方式的詳細資訊,請參閱 Visual Studio 偵錯工具初探頁面。For more information about the debugger and how it works, see the First look at the Visual Studio debugger page.

修正「除以零」錯誤Fix the "divide by zero" error

當您嘗試將數字除以零時,主控台應用程式會凍結。When you try to divide a number by zero, the console app freezes. Visual Studio 接著會顯示程式碼編輯器中的錯誤。Visual Studio then shows you what's wrong in the code editor.

Visual Studio 程式碼編輯器顯示「除以零」錯誤

讓我們變更程式碼來處理此錯誤。Let's change the code to handle this error.

  1. 刪除直接出現在 case "d": 和指出 // Wait for the user to respond before closing 之註解間的程式碼。Delete the code that appears directly between case "d": and the comment that says // Wait for the user to respond before closing.

  2. 使用下列程式碼將其取代:Replace it with the following code:

             // Ask the user to enter a non-zero divisor until they do so.
                 while (num2 == 0)
                 {
                     Console.WriteLine("Enter a non-zero divisor: ");
                     num2 = Convert.ToInt32(Console.ReadLine());
                 }
                 Console.WriteLine($"Your result: {num1} / {num2} = " + (num1 / num2));
                 break;
         }
    

    新增程式碼後,具有 switch 陳述式的區段看起來會類似下列螢幕擷取畫面:After you add the code, the section with the switch statement should look similar to the following screenshot:

    Visual Studio 程式碼編輯器中經修改的「切換」區段

現在,當您將任何數字除以零時,應用程式會要求輸入其他數字。Now, when you divide any number by zero, the app will ask for another number. 不只是如此:應用程式會持續要求直到您提供非零的數字。Even better: It won't stop asking until you provide a number other than zero.

Visual Studio 程式碼編輯器顯示「除以零」錯誤

修正「格式」錯誤Fix the "format" error

如果應用程式僅接受數字字元,而您輸入了英文字元 (反之亦然),則主控台應用程式會凍結。If you enter an alpha character when the app expects a numeric character (or vice versa), the console app freezes. Visual Studio 接著會顯示程式碼編輯器中的錯誤。Visual Studio then shows you what's wrong in the code editor.

Visual Studio 程式碼編輯器顯示格式錯誤

若要修正此錯誤,我們必須重構先前輸入的程式碼。To fix this error, we must refactor the code that we've previously entered.

修改程式碼Revise the code

我們將應用程式分為兩類:CalculatorProgram,而不依賴 program 類別來處理所有程式碼。Rather than rely on the program class to handle all the code, we'll divide our app into two classes: Calculator and Program.

Calculator 類別會處理大量計算工作,Program 類別會處理使用者介面和錯誤擷取工作。The Calculator class will handle the bulk of the calculation work, and the Program class will handle the user interface and error-capturing work.

我們現在就開始吧。Let's get started.

  1. 刪除下列程式碼區塊「之後」 的所有項目:Delete everything after the following code block:

    
    using System;
    
    namespace Calculator
    {
    
    
  2. 接下來,新增 Calculator 類別,如下所示:Next, add a new Calculator class, as follows:

    class Calculator
    {
        public static double DoOperation(double num1, double num2, string op)
        {
            double result = double.NaN; // Default value is "not-a-number" which we use if an operation, such as division, could result in an error.
    
            // Use a switch statement to do the math.
            switch (op)
            {
                case "a":
                    result = num1 + num2;
                    break;
                case "s":
                    result = num1 - num2;
                    break;
                case "m":
                    result = num1 * num2;
                    break;
                case "d":
                    // Ask the user to enter a non-zero divisor.
                    if (num2 != 0)
                    {
                        result = num1 / num2;
                    }
                    break;
                // Return text for an incorrect option entry.
                default:
                    break;
            }
            return result;
        }
    }
    
    
  3. 然後,新增 Program 類別,如下所示:Then, add a new Program class, as follows:

    class Program
    {
        static void Main(string[] args)
        {
            bool endApp = false;
            // Display title as the C# console calculator app.
            Console.WriteLine("Console Calculator in C#\r");
            Console.WriteLine("------------------------\n");
    
            while (!endApp)
            {
                // Declare variables and set to empty.
                string numInput1 = "";
                string numInput2 = "";
                double result = 0;
    
                // Ask the user to type the first number.
                Console.Write("Type a number, and then press Enter: ");
                numInput1 = Console.ReadLine();
    
                double cleanNum1 = 0;
                while (!double.TryParse(numInput1, out cleanNum1))
                {
                    Console.Write("This is not valid input. Please enter an integer value: ");
                    numInput1 = Console.ReadLine();
                }
    
                // Ask the user to type the second number.
                Console.Write("Type another number, and then press Enter: ");
                numInput2 = Console.ReadLine();
    
                double cleanNum2 = 0;
                while (!double.TryParse(numInput2, out cleanNum2))
                {
                    Console.Write("This is not valid input. Please enter an integer value: ");
                    numInput2 = Console.ReadLine();
                }
    
                // Ask the user to choose an operator.
                Console.WriteLine("Choose an operator from the following list:");
                Console.WriteLine("\ta - Add");
                Console.WriteLine("\ts - Subtract");
                Console.WriteLine("\tm - Multiply");
                Console.WriteLine("\td - Divide");
                Console.Write("Your option? ");
    
                string op = Console.ReadLine();
    
                try
                {
                    result = Calculator.DoOperation(cleanNum1, cleanNum2, op);
                    if (double.IsNaN(result))
                    {
                        Console.WriteLine("This operation will result in a mathematical error.\n");
                    }
                    else Console.WriteLine("Your result: {0:0.##}\n", result);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Oh no! An exception occurred trying to do the math.\n - Details: " + e.Message);
                }
    
                Console.WriteLine("------------------------\n");
    
                // Wait for the user to respond before closing.
                Console.Write("Press 'n' and Enter to close the app, or press any other key and Enter to continue: ");
                if (Console.ReadLine() == "n") endApp = true;
    
                Console.WriteLine("\n"); // Friendly linespacing.
            }
            return;
        }
    }
    
  4. 選擇 [Calculator] 來執行您的程式 (或按 F5)。Choose Calculator to run your program, or press F5.

  5. 遵循提示,將數字 42 除以數字 119Follow the prompts and divide the number 42 by the number 119. 您的應用程式看起來應該類似下列螢幕擷取畫面:Your app should look similar to the following screenshot:

    主控台視窗顯示重構的應用程式,包含要採取那些動作和處理不正確輸入的提示

    請注意,在您關閉主控台應用程式前,您可以選擇輸入其他方程式。Notice that you have the option to enter more equations until you choose to close the console app. 此外,我們也減少了結果中的小數位數。And, we've also reduced the number of decimal places in the result.

關閉應用程式Close the app

  1. 如果您尚未這麼做,請關閉計算機應用程式。If you haven't already done so, close the calculator app.

  2. 關閉 Visual Studio 中的 [輸出] 窗格。Close the Output pane in Visual Studio.

    關閉 Visual Studio 中的 [輸出] 窗格

  3. 在 Visual Studio 中,按 Ctrl+S 來儲存您的應用程式。In Visual Studio, press Ctrl+S to save your app.

  4. 關閉 Visual Studio。Close Visual Studio.

程式碼完成Code complete

在本教學課程中,我們對計算機應用程式進行了許多變更。During this tutorial, we've made a lot of changes to the calculator app. 應用程式現在會更有效率處理運算資源,並處理大部分的使用者輸入錯誤。The app now handles computing resources more efficiently, and it handles most user input errors.

以下是完整程式碼總整理:Here's the complete code, all in one place:


using System;

namespace Calculator
{
    class Calculator
    {
        public static double DoOperation(double num1, double num2, string op)
        {
            double result = double.NaN; // Default value is "not-a-number" which we use if an operation, such as division, could result in an error.

            // Use a switch statement to do the math.
            switch (op)
            {
                case "a":
                    result = num1 + num2;
                    break;
                case "s":
                    result = num1 - num2;
                    break;
                case "m":
                    result = num1 * num2;
                    break;
                case "d":
                    // Ask the user to enter a non-zero divisor.
                    if (num2 != 0)
                    {
                        result = num1 / num2;
                    }
                    break;
                // Return text for an incorrect option entry.
                default:
                    break;
            }
            return result;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            bool endApp = false;
            // Display title as the C# console calculator app.
            Console.WriteLine("Console Calculator in C#\r");
            Console.WriteLine("------------------------\n");

            while (!endApp)
            {
                // Declare variables and set to empty.
                string numInput1 = "";
                string numInput2 = "";
                double result = 0;

                // Ask the user to type the first number.
                Console.Write("Type a number, and then press Enter: ");
                numInput1 = Console.ReadLine();

                double cleanNum1 = 0;
                while (!double.TryParse(numInput1, out cleanNum1))
                {
                    Console.Write("This is not valid input. Please enter an integer value: ");
                    numInput1 = Console.ReadLine();
                }

                // Ask the user to type the second number.
                Console.Write("Type another number, and then press Enter: ");
                numInput2 = Console.ReadLine();

                double cleanNum2 = 0;
                while (!double.TryParse(numInput2, out cleanNum2))
                {
                    Console.Write("This is not valid input. Please enter an integer value: ");
                    numInput2 = Console.ReadLine();
                }

                // Ask the user to choose an operator.
                Console.WriteLine("Choose an operator from the following list:");
                Console.WriteLine("\ta - Add");
                Console.WriteLine("\ts - Subtract");
                Console.WriteLine("\tm - Multiply");
                Console.WriteLine("\td - Divide");
                Console.Write("Your option? ");

                string op = Console.ReadLine();

                try
                {
                    result = Calculator.DoOperation(cleanNum1, cleanNum2, op);
                    if (double.IsNaN(result))
                    {
                        Console.WriteLine("This operation will result in a mathematical error.\n");
                    }
                    else Console.WriteLine("Your result: {0:0.##}\n", result);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Oh no! An exception occurred trying to do the math.\n - Details: " + e.Message);
                }

                Console.WriteLine("------------------------\n");

                // Wait for the user to respond before closing.
                Console.Write("Press 'n' and Enter to close the app, or press any other key and Enter to continue: ");
                if (Console.ReadLine() == "n") endApp = true;

                Console.WriteLine("\n"); // Friendly linespacing.
            }
            return;
        }
    }
}

後續步驟Next steps

恭喜您完成此教學課程!Congratulations on completing this tutorial! 若要更深入了解,請繼續下列教學課程。To learn even more, continue with the following tutorials.

另請參閱See also