Thread: does C# have pointers??

  1. #1
    C 1337 Meshal's Avatar
    Join Date
    Nov 2006
    Posts
    70

    does C# have pointers??

    does c# have pointers !!

    and if the answer is no ..

    how can i implement the static/dynamic hashing?

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    The answer is yes and yes and no.

    Basically, every reference type in .NET is a pointer.

    You can have explicit pointers in unmanaged code including a ton of complications that come with the full unmanaged package.

    And no, to the user, nothing in C# is handled like a pointer. There is no dereferencing or an -> operator.


    I don't really know what you mean with dynamic/static hashing, but you can implement it in C#. Maybe you can explain what you want to achieve.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    C 1337 Meshal's Avatar
    Join Date
    Nov 2006
    Posts
    70
    thanks for answers my questions ..

    and what i mean by static and dynamic hashing is this:
    statick-hashing
    http://www.cs.sfu.ca/CC/354/zaiane/m...00000000000000
    http://www.dis.uniroma1.it/~catarci/...3LT/sld003.htm

    dynamic hashing(extensible hashing)
    http://www.dis.uniroma1.it/~catarci/...3LT/sld005.htm

    how can i implement those hashing technique in C# , because i need a pointer to point to the buckets

    buckets = blocks

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    You use references to point to the buckets, in simple, standard C#. There's nothing special about hashing in this regard.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  5. #5
    C 1337 Meshal's Avatar
    Join Date
    Nov 2006
    Posts
    70
    how i can reference to point to the bucket ??

    can you show me an example ?!

  6. #6
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Code:
    Bucket[] buckets = new Bucket[numBuckets];
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  7. #7
    Registered User
    Join Date
    Apr 2007
    Posts
    45
    Yeah gotta love C# for this particular ambiguity
    we are one

  8. #8
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Which one?
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  9. #9
    Registered User
    Join Date
    Apr 2007
    Posts
    45
    Its illustrious memory handling
    we are one

  10. #10
    C 1337 Meshal's Avatar
    Join Date
    Nov 2006
    Posts
    70
    so how can binary tree or binary search programmed in C# without using real pointers ?!!

  11. #11
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    C# has pointers. It's just that C# has nothing else that's probably a bit confusing. Every reference type in C# is what C++ would call a pointer. You just don't need to free the memory, because it's managed/garbage collected. And you don't need those pointer semantics/syntactics, because the compiler already knows if something is a pointer ( reference type ) or not ( value type ).

    CObject* o = new CObject( "test" ); // perfectly valid C++

    Object o = new Object( "test" ); // perfectly valid C#

    Those two lines are exactly the same. An object is created dynamically.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  12. #12
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,246
    C# supports C++ type pointers. But it is called unsafe code. It is better to use .NET standard libs for those kind of operations OR you may go to MSDN for unsafe code.
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using pointers to pointers
    By steve1_rm in forum C Programming
    Replies: 18
    Last Post: 05-29-2008, 05:59 AM
  2. function pointers
    By benhaldor in forum C Programming
    Replies: 4
    Last Post: 08-19-2007, 10:56 AM
  3. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  4. Staticly Bound Member Function Pointers
    By Polymorphic OOP in forum C++ Programming
    Replies: 29
    Last Post: 11-28-2002, 01:18 PM