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. Visual Basic
  4. a new coding style which I came across

a new coding style which I came across

Scheduled Pinned Locked Moved Visual Basic
csharp
5 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.
  • U Offline
    U Offline
    User 3055467
    wrote on last edited by
    #1

    Hi, I am completely new to .NET 3.5.I came across a code in vb.net which I am not able to understand. Below is the code <flags()> Public Enum ModemStatusBits ClearToSendOn = &H10 DataSetReadyOn = &H20 End Enum <structlayout(layoutkind.sequential,pack:> Private Structure DCB Public DCBlength As Integer Public BaudRate As Integer Public Bits1 As Integer End Structure <dllimport("kernel32.dll")> Private Shared Function WaitForSingleObject( _ ByVal hHandle As Integer, ByVal dwMilliseconds As Integer) As Integer End Function here what does he mean by putting something in <> before enum,struct,Function Thanks in advance

    B 1 Reply Last reply
    0
    • U User 3055467

      Hi, I am completely new to .NET 3.5.I came across a code in vb.net which I am not able to understand. Below is the code <flags()> Public Enum ModemStatusBits ClearToSendOn = &H10 DataSetReadyOn = &H20 End Enum <structlayout(layoutkind.sequential,pack:> Private Structure DCB Public DCBlength As Integer Public BaudRate As Integer Public Bits1 As Integer End Structure <dllimport("kernel32.dll")> Private Shared Function WaitForSingleObject( _ ByVal hHandle As Integer, ByVal dwMilliseconds As Integer) As Integer End Function here what does he mean by putting something in <> before enum,struct,Function Thanks in advance

      B Offline
      B Offline
      Bharat Jain
      wrote on last edited by
      #2

      These are called attributes, this not something very new , the code above seems to use a native windows API (Windows API can be considered as functions provided by OS , to be able to program the OS), This Windows API are present in the dll files Kernel32.dll , GDI32.dll, etc , so in above code we are using attribute "<dllimport("kernel32.dll")>" to tell the compiler that we want to use a windows function WaitForSingleObject() which is present in Kernel32.dll , in the same way we want the compiler to allocate the memory in sequential order hence use an attribute <structlayout(layoutkind.sequential,pack:> (the reason for this sequential allocation is a different topic , let me know if you want details regarding the reason , for now I will skip it :)) Hope this make things clear, let me know if you need further information

      -Regards Bharat Jain bharat.jain.nagpur@gmail.com

      U 1 Reply Last reply
      0
      • B Bharat Jain

        These are called attributes, this not something very new , the code above seems to use a native windows API (Windows API can be considered as functions provided by OS , to be able to program the OS), This Windows API are present in the dll files Kernel32.dll , GDI32.dll, etc , so in above code we are using attribute "<dllimport("kernel32.dll")>" to tell the compiler that we want to use a windows function WaitForSingleObject() which is present in Kernel32.dll , in the same way we want the compiler to allocate the memory in sequential order hence use an attribute <structlayout(layoutkind.sequential,pack:> (the reason for this sequential allocation is a different topic , let me know if you want details regarding the reason , for now I will skip it :)) Hope this make things clear, let me know if you need further information

        -Regards Bharat Jain bharat.jain.nagpur@gmail.com

        U Offline
        U Offline
        User 3055467
        wrote on last edited by
        #3

        Hi Bharat Thanks a lot for replying so soon. I want to know in detail about this feature attributes.How to use that and what are the advantages. If you dont mind can you give a url or some tutorial describing about this. My mail id is poornachandarv_004@hotmail.com Thanks a lot

        0 B 2 Replies Last reply
        0
        • U User 3055467

          Hi Bharat Thanks a lot for replying so soon. I want to know in detail about this feature attributes.How to use that and what are the advantages. If you dont mind can you give a url or some tutorial describing about this. My mail id is poornachandarv_004@hotmail.com Thanks a lot

          0 Offline
          0 Offline
          0x3c0
          wrote on last edited by
          #4

          MSDN documentation[^]

          1 Reply Last reply
          0
          • U User 3055467

            Hi Bharat Thanks a lot for replying so soon. I want to know in detail about this feature attributes.How to use that and what are the advantages. If you dont mind can you give a url or some tutorial describing about this. My mail id is poornachandarv_004@hotmail.com Thanks a lot

            B Offline
            B Offline
            Bharat Jain
            wrote on last edited by
            #5

            Ya that is true the best way to learn is MSDN documents , also use the intellisense in Visual Studios , it would be too hard to mention about all attributes , but if you have specific doubts , may be i can help

            -Regards Bharat Jain bharat.jain.nagpur@gmail.com

            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