小编sik*_*rma的帖子

如果已经有一个具有相同名称的局部变量,如何在函数内部使用全局变量

  • 想要从函数内部调用全局变量,而不是已经存在同名的局部变量;
  • 我试过这个.

using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Globalization;
    namespace tesitingInMyKitchen
    {
        class program
        {
           static string cheese = "chedar";

            static void Main()
            {
                string cheese = "swiss";
                //printing local cheese
                Console.WriteLine(cheese);
                //here want to print global cheese 
                Console.WriteLine(global :cheese);
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

.net c# c#-4.0

0
推荐指数
1
解决办法
523
查看次数

如何使用比较委托对类的字符串属性进行排序

这是我的代码.我正在尝试使用比较委托进行比较.(在visual studio code .net core中).

using System;
using System.Collections.Generic;
namespace comparisionProject
{
    public class student
    {
        public int SId { get; set; }
        public string name { get; set; }
        public int FullMarks { get; set; }=600;
        public int Marks { get; set; }

    }

    public class tester
    {
        public static int CompareNames(student std1, student std2)
        {
            return std1.name.CompareTo(std1.name);
        }
        static void Main(string[] args)
        {
            student s1 = new student(){SId=101 , name = "kalu",Marks = 456 };
            student s2 = …
Run Code Online (Sandbox Code Playgroud)

.net c# delegates .net-core

0
推荐指数
1
解决办法
106
查看次数

标签 统计

.net ×2

c# ×2

.net-core ×1

c#-4.0 ×1

delegates ×1