Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Initializing dictionary with a struct? help pls

Initializing dictionary with a struct? help pls

Scheduled Pinned Locked Moved C#
helpquestioncssdotnet
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    honeyman_can
    wrote on last edited by
    #1

    Hi guys what is wrong with this line? lookupObject is a struct. I just want to initialize the dictionary with the struct as value. public static Dictionary dicTextLookup = new Dictionary(); this is the error: "Error 1 Inconsistent accessibility: field type 'System.Collections.Generic.Dictionary' is less accessible than field 'dicTextLookup' C:\IL\TranslationController.cs 44" Thanks

    J 1 Reply Last reply
    0
    • H honeyman_can

      Hi guys what is wrong with this line? lookupObject is a struct. I just want to initialize the dictionary with the struct as value. public static Dictionary dicTextLookup = new Dictionary(); this is the error: "Error 1 Inconsistent accessibility: field type 'System.Collections.Generic.Dictionary' is less accessible than field 'dicTextLookup' C:\IL\TranslationController.cs 44" Thanks

      J Offline
      J Offline
      Judah Gabriel Himango
      wrote on last edited by
      #2

      Could you repost that snippet, but check the "Ignore HTML tags in this message" checkbox when posting? We can't see your full code otherwise. Is dicTextLookup non-public? Are you exposing the field as public? This error typically occurs if you're trying to expose some private/protected/internal thing as public. For instance

      private class MyFoo {}

      public class MyBar()
      {
      public MyFoo instance; // Error: inconsistent visibility: MyFoo is private, yet we're trying to expose the field as public
      }

      H 1 Reply Last reply
      0
      • J Judah Gabriel Himango

        Could you repost that snippet, but check the "Ignore HTML tags in this message" checkbox when posting? We can't see your full code otherwise. Is dicTextLookup non-public? Are you exposing the field as public? This error typically occurs if you're trying to expose some private/protected/internal thing as public. For instance

        private class MyFoo {}

        public class MyBar()
        {
        public MyFoo instance; // Error: inconsistent visibility: MyFoo is private, yet we're trying to expose the field as public
        }

        H Offline
        H Offline
        honeyman_can
        wrote on last edited by
        #3

        Sorry I didnt know about checking the checkbox, you solved my problem without looking at my code. Great!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups