-4
我有一个公共类,我试图在另一个项目中引用它。它有一个构造函数:由于其保护级别而无法访问公共类
namespace Stuff
{
struct Vector
{
public double x { get; set; }
public double y { get; set; }
public double z { get; set; }
public Vector (double ex, double why, double zee)
{
this.x = ex;
this.y = why;
this.z = zee;
}
...
,我不断收到inaccessible due to protection level
错误。
这是我怎样,我引用它在另一个项目:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Stuff;
namespace ProjectileMotion
{
class Projectile
{
private Vector acceleration = new Vector(0, 0, -9.8); //the acceleration is a vector now.
...
类“向量”是在一个名为“东西”项目 - 它需要一个更好的名字。
声明'Vector'结构为public并且再次尝试 – Zippy
很明显它不是'public' –
您的结构不是类,它不是公共的。为了公开添加'public struct Vector' – serhiyb