【问题标题】:Why i'm getting Inconsistent accessibility: field type .... is less accessible than field ? And how to fix it?为什么我得到不一致的可访问性:字段类型 .... 比字段更难访问?以及如何解决?
【发布时间】:2015-06-30 04:18:00
【问题描述】:
Error   1   Inconsistent accessibility: field type 'Youtube_Manager.Ffmpeg' is less accessible than field 'Youtube_Manager.ScreenShot.fmpeg'

在我添加的班级顶部:

using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using System.ComponentModel;


    namespace Youtube_Manager
    {
        public class ScreenShot
        {

        #region Global Variables
            public static Ffmpeg fmpeg;

然后我在计时器点击事件中调用另一个类中的 fmpeg:

ScreenShot.fmpeg.Close();

我在 fmpeg 上的 ScreenShot 类中出现错误:

错误 1 ​​可访问性不一致:字段类型“Youtube_Manager.Ffmpeg”的可访问性低于字段“Youtube_Manager.ScreenShot.fmpeg

这是Ffmpeg类的顶部:

using System;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using System.IO.Pipes;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.IO;
using DannyGeneral;

namespace Youtube_Manager
{
    class Ffmpeg
    {
        NamedPipeServerStream p;
        String pipename = "mytestpipe";
        System.Diagnostics.Process process;
        string ffmpegFileName = "ffmpeg.exe";
        string workingDirectory;

        public Ffmpeg()
        {

即使我将变量 fmpeg 从静态更改为公共,我也会遇到同样的错误。

【问题讨论】:

  • static和public没有任何关系,public是访问修饰符,static指的是如何调用方法

标签: c# .net winforms


【解决方案1】:

默认情况下,顶级 C# classes 是内部的。内部的知名度低于公众。使用public class Ffmpeg 公开课程。

【讨论】:

    猜你喜欢
    • 2023-03-24
    • 2012-10-11
    • 2014-06-25
    • 1970-01-01
    • 2018-03-07
    • 1970-01-01
    • 1970-01-01
    • 2012-10-27
    相关资源
    最近更新 更多