Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9040127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:54:27+00:00 2026-06-16T09:54:27+00:00

I encountered a snippet of C# source code as following int* ptr = …;

  • 0

I encountered a snippet of C# source code as following

int* ptr = ...;
int  w = ...;

int* ptr3 = ptr + (IntPtr)w;

CS0019: Operator '+' cannot be applied to operands of type 'int*' and 'System.IntPtr'

I guess this code was trying to move the ptr address forward by w which is dependent on the OS. Is this correct and how can I make this code compile?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T09:54:29+00:00Added an answer on June 16, 2026 at 9:54 am

    No, it is not correct syntax. It is very unclear what you are trying to accomplish so just guessing here. If you want to move the pointer forward by “w” ints then use:

      int* ptr3 = ptr + w;
    

    Which adds 4*w to the pointer value since an int is 4 bytes. This is equivalent to treating ptr3 as a pointer into an array of ints where w is the array element offset. And the way the C language treats pointers.

    If you meant to increment the address by w then avoid using IntPtr, the C# language forbids using the + operator on an IntPtr, even though that’s permitted by the CLR. You’ll need to do some casting instead:

      int* ptr3 = (int*)((byte*)ptr + w);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I was browsing the Linux code I encountered the following snippet : static
I have encountered the following snippet: pt->aa[!!(ts->flags & MASK)] = -val; What does !!
W/hen i run the following code snippet #!/bin/bash if [ foo = foo ];
I encountered a snippet of code like: from object_recognition_msgs.msg import * In my opinion,
I encountered the following problem after upgrading to the latest version 1.8.1 of data.table
I encountered this error: Cannot implicitly convert type System.Web.UI.WebControls.LoginView to Login The error occured
Following is a snippet that throws java.lang.NullPointerException . else if(jRadioButton2.isSelected()) { // chrome selected
I've encountered code with setup like this: internal class Something { public string Name
Below is my python snippet code to upload a file on certain server: import
I have some code which is trying to load a Dll. I have encountered

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.