-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