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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. DataTable's question in class ?

DataTable's question in class ?

Scheduled Pinned Locked Moved .NET (Core and Framework)
questionhelp
3 Posts 3 Posters 1 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.
  • B Offline
    B Offline
    bluehai
    wrote on last edited by
    #1

    Please tell me why I received errors when doing this: class MyClass : DataTable { public MyClass():base() { DataTable dt = new DataTable(); this = dt;// errors occur here, what can I do to let dt to "this" } } Thank you for your help.

    R J 2 Replies Last reply
    0
    • B bluehai

      Please tell me why I received errors when doing this: class MyClass : DataTable { public MyClass():base() { DataTable dt = new DataTable(); this = dt;// errors occur here, what can I do to let dt to "this" } } Thank you for your help.

      R Offline
      R Offline
      Robert Rohde
      wrote on last edited by
      #2

      What are you trying to do? When inheriting from DataTable then this is already a new empty DataTable. You could right there start adding data:

      class MyClass : DataTable
      {
      public MyClass():base()
      {
      this.Columns.Add(...);
      this.Rows.Add(...);
      }
      }

      1 Reply Last reply
      0
      • B bluehai

        Please tell me why I received errors when doing this: class MyClass : DataTable { public MyClass():base() { DataTable dt = new DataTable(); this = dt;// errors occur here, what can I do to let dt to "this" } } Thank you for your help.

        J Offline
        J Offline
        Josh Smith
        wrote on last edited by
        #3

        This question is not really about the DataTable class. The this reference is always read-only, regardless of where it is being used. Josh

        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