Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
8
Reply
Expert to C# Help Me!
Chung Le Kha
Nov 2 2009 1:30 PM
2.6k
Reply
I am learning about the programming language C #. to the use of
unsafe code and pointers in C #
.
and this is all my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
struct Location
{
public int X;
public int Y;
}
unsafe static void Main(string[] args)
{
Location loc;
loc.X = 100;
loc.Y = 100;
Location* loc_ptr;
loc_ptr = &loc;
Console.WriteLine("X = {0}", loc_ptr->X);
loc_ptr->X = 200;
Console.WriteLine("X = {0}", loc_ptr->X);
}
}
}
the code is in error as follows:
unsafe code may only appear if compiling
with/unsafe
// I tried and then move consoleapplication but it failed. and error is so
//Hope the experts help answer helped me
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
8
)
Next Recommended Forum
Sum problem
BackgroundWorker Tools