473,388 Members | 1,526 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

What is the counterpart of this C pointer programme in C#?

88 64KB
I'd like to know how the following programme on pointer written in C can be written in C#, especially how to use the keywords in the C programme like &i and *p in C#. Please clarify.

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2.  
  3. void f(int *p, int *q)
  4. {
  5.     p = q;
  6.     *p = 2;
  7. }
  8.  
  9. int i = 0, j = 1;
  10.  
  11. int main()
  12. {
  13.     f(&i, &j);
  14.     printf("%d %d \n", i, j);
  15.     return 0;
  16. }
Mar 18 '21 #1
2 3369
dev7060
636 Expert 512MB
I'd like to know how the following programme on pointer written in C can be written in C#, especially how to use the keywords in the C programme like &i and *p in C#. Please clarify.
https://docs.microsoft.com/en-us/dot...eywords/unsafe
Mar 18 '21 #2
priyamtheone
88 64KB
@dev7060: The MSDN link you provided along with this link provide a basic concept on how to use the address-of operator and the pointer indirection operator while working with pointer concepts in C#. Thanks for the reference.
Mar 19 '21 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: opistobranchia | last post by:
I was on a job interview and the interviewer asked what "this" meant. I replied it represented this class like cout << a or cout << this.a then he asked what this meant if it was static? I...
11
by: J Wang | last post by:
dear, I debug the program recently as follows. #include <sys/stat.h> int main(int argc, char *argv) { struct stat buf;
10
by: sabarish | last post by:
hi friend, what is function pointer how it is useful? plz help me.
2
by: Nuno Esculcas | last post by:
Hello, I come from C++ and i now have to work with C#, and someone tell me that bye bye pointers but i think this is not true, i must convert a DIB image in something that i can use in C# (like...
1
by: Alvo von Cossel I | last post by:
hi, i have been browsing my toolbox very carefully and have encountered a pointer object. what is this pointer? and why cant i drag it into my design window? -- Alvo von Cossel I of Germany
5
by: Niu Xiao | last post by:
I saw a lot of codes like: void foo(void* arg) void bar(void** arg) f((void*)p) but what does void pointer mean in c? I just know it stands for generic pointer. thanks.
3
by: john | last post by:
Hey, I know we use the pointer this to obtain a class object or class member data. I don't follow the reason for example this code. I'am quite confused assingment operator const B...
92
by: Heinrich Pumpernickel | last post by:
what does this warning mean ? #include <stdio.h> int main() { long l = 100; printf("l is %li\n", l * 10L);
20
by: prashant.khade1623 | last post by:
I am not getting the exact idea. Can you please explain me with an example. Thanks
19
by: Eric | last post by:
What is this? ( char * ) &( ( struct aStruct * ) 0 ) It looks like it's taking the address of something that contains a pointer to null, and casting it to a pointer to char. (Actually,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.