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. Windows Forms
  4. global logininformation

global logininformation

Scheduled Pinned Locked Moved Windows Forms
questioncsharphelp
3 Posts 3 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.
  • J Offline
    J Offline
    jogisarge
    wrote on last edited by
    #1

    Hi, i have an application with my own Login-System. When a user starts the app and loggs correct in,i want to store user-data in a class "Logininformation". i have to access the Logininformation class in many other forms. How could this be done ? I know that global Vars are not allowed in C#, but how can i get this problem done ? bye jogi

    N W 2 Replies Last reply
    0
    • J jogisarge

      Hi, i have an application with my own Login-System. When a user starts the app and loggs correct in,i want to store user-data in a class "Logininformation". i have to access the Logininformation class in many other forms. How could this be done ? I know that global Vars are not allowed in C#, but how can i get this problem done ? bye jogi

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      There are many ways to do it. You could persist the information, such in a database. You could also pass the information between forms (least favorable), or have a singleton object that is shared between the forms.


      only two letters away from being an asset

      1 Reply Last reply
      0
      • J jogisarge

        Hi, i have an application with my own Login-System. When a user starts the app and loggs correct in,i want to store user-data in a class "Logininformation". i have to access the Logininformation class in many other forms. How could this be done ? I know that global Vars are not allowed in C#, but how can i get this problem done ? bye jogi

        W Offline
        W Offline
        Wendelius
        wrote on last edited by
        #3

        You can simply define the class as static. For example:

        internal static class Logininformation {
        private static string username;
        ...
        internal static string UserName {
        get {
        return username;
        }
        set {
        username = value;
        }
        }
        ...

        The need to optimize rises from a bad design.My articles[^]

        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