天天看點

C#練習題答案: GetThePlusMethod【難度:1級】--景越C#經典程式設計題庫,1000道C#基礎練習題等你來挑戰答案1:答案2:答案3:答案4:答案5:答案6:答案7:答案8:答案9:答案10:答案11:答案12:答案13:

GetThePlusMethod【難度:1級】:

答案1:

using System;
public static class Kata{
  public static Func<int, int> MethodFunc(int i){
    return x=>x+i;
  }
}​

           

答案2:

using System;
using System.Collections.Generic;

public static class Kata
    {
        public static Func<int, int> MethodFunc(int i)
        {
           return x => x + i;
        }
    }​

           

答案3:

using System;
using System.Collections.Generic;

public static class Kata
    {
        public static Func<int, int> MethodFunc(int i)
        {
            return (x) => x + i;
        }
    }​

           

答案4:

using System;
using System.Collections.Generic;

public static class Kata
    {
        public static Func<int, int> MethodFunc(int i)
        {
            return ((x) => (x + i));
        }
    }​

           

答案5:

using System;
using System.Collections.Generic;

public static class Kata
{
    public static Func<int, int> MethodFunc(int i)
    {
        return o => i + o;
    }
}​

           

答案6:

using System;
using System.Collections.Generic;

public static class Kata
{
  public static Func<int, int> MethodFunc(int i)
  {
    return val => val + i;
  }
}​

           

答案7:

using System;
using System.Collections.Generic;

public static class Kata
    {
        public static Func<int, int> MethodFunc(int i)
        {
            return (int x) => x + i;
        }
    }​

           

答案8:

using System;
using System.Collections.Generic;

public static class Kata
    {
        public static Func<int, int> MethodFunc(int i)
        {
            return (b) => i + b;
        }
    }​

           

答案9:

using System;
using System.Collections.Generic;
using System.Linq;

public static class Kata
    {
        public static Func<int, int> MethodFunc(int i)
        {
          Func<int, int> cal = x => x + i;
          return cal;
        }
    }​

           

答案10:

using System;
using System.Collections.Generic;

public static class Kata {
    public static Func<int, int> MethodFunc(int X) {
        return V => X + V;
    }
}​

           

答案11:

using System;
  public static class Kata
    {
        public static Func<int, int> MethodFunc(int i)
        {
            if (i == 1)
            {
                Func<int, int> plus1 = delegate (int n) { return n + i; };
                return plus1;
            }
            if (i == 2)
            {
                Func<int, int> plus2 = delegate (int n) { return n + i; };
                return plus2;
            }
            if (i == 3)
            {
                Func<int, int> plus3 = delegate (int n) { return n + i; };
                return plus3;
            }
            Func<int, int> plus = delegate (int n) { return n + i; };
            return plus;
        }
    }​

           

答案12:

using System;
using System.Collections.Generic;

public static class Kata
{
    public static Func<int, int> MethodFunc(int i)
    {
        return x => i + x;
    }
 }​

           

答案13:

using System;
using System.Collections.Generic;

public static class Kata
    {
        public static Func<int, int> MethodFunc(int i)
        {
            return new Func<int, int>(x => x + i);
        }
    }​

           

繼續閱讀