【发布时间】:2021-05-30 16:55:29
【问题描述】:
如何使用 Visual Studio 覆盖 C# 中的基类构造函数,我尝试调用它,但编译器报告错误 MyGLSurfaceView 不包含采用 0 个参数的构造函数,但我在构造函数实现中有一个参数请帮忙..
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.Opengl;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
namespace Painting
{
class MyGLSurfaceView : GLSurfaceView
{
Context mycontext;
private readonly MyGlRenderer render;
// Constructor with one argument
// Compiler reports an error saying this constructor does not take 0 arguments
public MyGLSurfaceView(Context context)
{
//
}
}
}
【问题讨论】:
-
为什么微软让人们在做android开发时将java转换为C#,而构造函数覆盖逻辑却有巨大的差异?
-
我的意思是在java中完成的所有其他事情都可以用C#完成,除了构造函数覆盖?
-
你试过
public MyGLSurfaceView(Context context) : base (context) { ...} -
不,我没有让我尝试
标签: c# android constructor base