Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Error CS0120 An object reference is required for the non-static field,
method, or property 'Blip.Sprite' HeliBoatMissions
namespace heliBoatMissions
{ }
public class Radar
{
void Marker()
{
new Blip(new Vector3(-699.4645f, -1448.289f, 5.000523f),
Blip.Sprite = BlipSprite.Helicopter);
}
}
I Think this is your issue
namespace heliBoatMissions
{ }
Change it to this
namespace heliBoatMissions
{
UPDATE
Also I noticed that you do not assign this
new Blip(new Vector3(-699.4645f, -1448.289f, 5.000523f),
to a variable. Nor do you end it with a semicolon.
I think something like this might be what you're after?
namespace heliBoatMissions
{
public class Radar
{
public object BlipSprite { get; private set; }
void Marker()
{
var v = new Blip(new Vector3(-699.4645f, -1448.289f, 5.000523f));
v.Sprite = BlipSprite.Helicopter;
}
}
}
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
public class Program
{
static void Main(string[] args)
{
Test test = new Test();
Console.WriteLine(test.GetType()); // -> it´s Test, of course
int a = 5;
Console.ReadLine();
}
}
public class Test
{
public string Name;
}
In the above case
the Type of "test" is Test, right?
And in this case the Type of "a" is int, named primitive data type,
public is an access modifier
So my Question now is, what is class then? A keyword? A primitive Datatype? Neither, Nor?
Please, don't explain my, what a class is doing or what's the difference between class or object, I know a class is like a construction plan.
Class is a keyword that signifies to the C# compiler that a class is being declared. See https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
How can I ignore mapping if some properties have different type with same name? By default it's throwing error.
I found some answers for an older versions of automapper but they are not working with the newest.
For example one property is string the other is bool but they both have the same name. The behaviour i want is to ignore them(not try to map them).
Here is a small example based on this link
Mapper.Initialize(cfg =>
{
cfg.CreateMap<Class1, Class2>();
cfg.ForAllMaps((typeMap, mappingExpr) =>
{
var ignoredPropMaps = typeMap.GetPropertyMaps();
foreach (var map in ignoredPropMaps)
{
var sourcePropInfo = map.SourceMember as PropertyInfo;
if (sourcePropInfo == null) continue;
if (sourcePropInfo.PropertyType != map.DestinationPropertyType)
map.Ignored = true;
}
});
});
Class1 src = new Class1()
{
TestProperty = "A"
};
Class2 dest = Mapper.Map<Class1, Class2>(src);
Test classes:
public class Class1
{
public string TestProperty { get; set; }
}
public class Class2
{
public bool TestProperty { get; set; }
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I have this C# class to send the data from DriveInfo Class to my window form:
using System;
public class FileSystemInfo
{
public string CheckTotalFreeSpace()
{
System.IO.DriveInfo DInfo = new System.IO.DriveInfo(#"C:\");
return DInfo.TotalFreeSpace.ToString();
}
public string CheckVolumeLabel()
{
System.IO.DriveInfo DInfo = new System.IO.DriveInfo(#"C:\");
return DInfo.VolumeLabel.ToString();
}
}
I want to send huge data from one class (see my example) into my form class (maybe labels or ListBox Control), by using a a good way to solve this issue. Also I don't want to put this line of code into separate c# class method:
System.IO.DriveInfo DInfo
The basic issue for me is: deal and show many info about my computer so I need to put all this info into one structure or something else.
You may use Lazy class:
using System.IO;
public class FileSystemInfo
{
private readonly Lazy<DriveInfo> dInfo =
new Lazy<DriveInfo>(() => new DriveInfo(#"C:\"));
public string CheckTotalFreeSpace()
{
return dInfo.Value.TotalFreeSpace.ToString();
}
public string CheckVolumeLabel()
{
return dInfo.Value.VolumeLabel.ToString();
}
}
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a handful of variables passed from one form to another, but now I'm realizing these variables can't be accessed outside the form method.
public Form3(int str, int dex, int vit, int arc, int hp, int mp, int sp, string name, string charClass)
{
...
}
I'd like to be able to access the arguments from other methods. Is it possible to increase the scope of these arguments within the class itself, or do I need to go to the roots and declare them differently?
Make them class-level members. For example:
public class Form3
{
private int Str { get; set; }
public Form3(int str)
{
Str = str;
}
private void SomeOtherMethod()
{
// here you can access Str
}
// other methods, etc.
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
How can I to check a property will be renewed or its value will be changed.
public MyClass A
{
get{}
set
{
// find if programmer set A=new MyClass();
}
}
It's not all clear what you want exactly, maybe something like this:
MyClass _a;
public MyClass A
{
get { return _a; }
set
{
// find if programmer set A=new MyClass();
if (value != _a)
{
// different value
}
}
}
For more complex scenario follow the suggestion of Raphaël Althaus and take a look at INotifyPropertyChanged.