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. What's the meaning of "|" and "@" in C#?

What's the meaning of "|" and "@" in C#?

Scheduled Pinned Locked Moved C#
csharptutorialquestionworkspace
5 Posts 5 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.
  • M Offline
    M Offline
    Ming Luo
    wrote on last edited by
    #1

    Dear All: Could anyone give me some useful articles about introducing the symbol "|" and "@" in C# please? For example, I saw a code something like:

    FileSystemWatcher fsm = new FileSystemWatcher(Environment.GetEnvironmentVariable("USERPROFILE"));

    fsm.NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite;

    Thanks

    Asura

    L W C 3 Replies Last reply
    0
    • M Ming Luo

      Dear All: Could anyone give me some useful articles about introducing the symbol "|" and "@" in C# please? For example, I saw a code something like:

      FileSystemWatcher fsm = new FileSystemWatcher(Environment.GetEnvironmentVariable("USERPROFILE"));

      fsm.NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite;

      Thanks

      Asura

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      The "|" means "or", can be found here[^]. The "@" symbol is mostly used with strings[^] :)

      I are Troll :suss:

      1 Reply Last reply
      0
      • M Ming Luo

        Dear All: Could anyone give me some useful articles about introducing the symbol "|" and "@" in C# please? For example, I saw a code something like:

        FileSystemWatcher fsm = new FileSystemWatcher(Environment.GetEnvironmentVariable("USERPROFILE"));

        fsm.NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite;

        Thanks

        Asura

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

        I think this two characters have nothing in common.

        Ming Luo wrote:

        "@"

        Is called a verbatim. Use of Verbatim[^] and

        Ming Luo wrote:

        "|"

        is a logical operator: http://en.wikibooks.org/wiki/C_Sharp_Programming/Operators[^]

        Wamuti: Any man can be an island, but islands to need water around them! Edmund Burke: No one could make a greater mistake than he who did nothing because he could do only a little.

        1 Reply Last reply
        0
        • M Ming Luo

          Dear All: Could anyone give me some useful articles about introducing the symbol "|" and "@" in C# please? For example, I saw a code something like:

          FileSystemWatcher fsm = new FileSystemWatcher(Environment.GetEnvironmentVariable("USERPROFILE"));

          fsm.NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite;

          Thanks

          Asura

          C Offline
          C Offline
          cooljeba1
          wrote on last edited by
          #4

          '|' is logical "OR' operator. '@' is used with strings to avoid escape characters. you can use like @"c:\hello.cs" ; instead of adding escape character for '\\'

          L 1 Reply Last reply
          0
          • C cooljeba1

            '|' is logical "OR' operator. '@' is used with strings to avoid escape characters. you can use like @"c:\hello.cs" ; instead of adding escape character for '\\'

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            cooljeba1 wrote:

            '|' is logical "OR' operator.

            '|' is bitwise 'OR' operator for integers (also logical 'OR' operator for booleans) '||' is logical 'OR' operator for booleans :)

            Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


            I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
            [The QA section does it automatically now, I hope we soon get it on regular forums as well]


            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