221 questions
0
votes
0
answers
62
views
.NET 8 not inline read-only auto-properties
I'm checking the Disassembly Window, when running a long test, with a warming phase, that uses swaps, swap legs and coupons. The test runs the valuation code a number enough of times for PGO to kick ...
0
votes
0
answers
87
views
How would I invoke setter when modifying properties in C#?
Suppose I have a class Character, which have stats of the class Stat. Specifically each character has a Character.Speed Stat that can be modified. This speed stat is heavily related to a float ...
0
votes
2
answers
106
views
Automatically update cells
I currently have this code for my worksheet:
Private Sub Worksheet_Change(ByVal Target As Range)
' ensure events are always enabled when we exit this Sub, even if we have an error
On Error ...
0
votes
0
answers
33
views
A method to use a formula if , and if not to tip a value manual inside, without VBA Excel
Hello and thanks for the help in advance.
Is there a way, for example, if cell A1 can say either yes or no, then I say in cell A2, if it says yes, then automatically write a word like "tree" ...
-1
votes
1
answer
131
views
Difference between two class definitions in c# [duplicate]
Failing finding an answer I can understand, could someone explain the difference between the following:
// One
private Guid mCategoryID;
public Guid CategoryID
{
get
{
return ...
1
vote
1
answer
39
views
Will use 'k_BackingField' cause version compatibility problem?
Recently, I'm working on serialization with C#.
I found that the automatic-properties' fields are named "<...>k_BackingField".
So my problem is dose this naming rule same in all .Net versions,...
-1
votes
2
answers
586
views
Object fingerprinting: serialization + untouchable legacy code + Getter-only auto-properties = cornered?
I have found myself cornered, so here we go.
Context
I need to produce a fingerprint hash code for object diffing. Comparing the hashes of two sets of objects will need to tell me if there are ...
0
votes
2
answers
707
views
Auto property initialization with anonymous function
I'm trying to get rid of some code with anonymous functions and classes.
I stuck on this:
public List<Object> Years { get; set; } = GetYears();
private static List<Object> GetYears()
{
...
0
votes
2
answers
839
views
Do auto implemented properties use private constructors for their initialization
I was reading Jon Skeet's C# in depth and came across the explanation for auto-implemented properties in C# 3.
The code for this was:
class Product
{
public string Name { get; private set; }
...
0
votes
2
answers
123
views
deleting unnecessary characters from txt document
I am facing a bit of a problem, i am not good at programming yet.
i have a text that looks like this:
D28151373 15-04 040 028230457 01-01 015 D28250305 01-08 048 D28250661 03-01 032 028151376 12-01 ...
22
votes
3
answers
27k
views
Expression-bodied properties vs. {get; set;} [duplicate]
When I have Visual Studio 2017 generate properties for me, it will always use the new expression-bodied properties, for example:
private static string username;
internal static string Username { get =...
0
votes
3
answers
6k
views
Update a class property based on another property's value in the setter
I have two model classes:
public class Person
{
public int PersonId { get; set; }
public string Name { get; set; }
public int AddressId { get; set; }
public Address AddressInfo { get; ...
0
votes
0
answers
54
views
Alter Auto-Property Behavior using Custom Attribute [duplicate]
I have a class with two different properties that map to the same value:
class MyClass {
public int Number { get; set; }
public string NumberString {
get { return Number.ToString(); }
...
0
votes
1
answer
2k
views
Property access modifiers with setters and getters
I have the following C# code:
class C
{
public int A { get; private set; }
}
How is the access modifier placed before the property type and name ('public' in this example) related to the ...
2
votes
3
answers
2k
views
When Do C# Auto-Properties Initialize?
On a webforms .aspx page system, the master page has a few properties auto initialized, as such
public bool MyProp => bool.Parse(Service.Settings["YorN"]);
Profiling page load, I see that between ...
31
votes
5
answers
18k
views
Getter without body, Setter with
I have a property which is currently automatic.
public string MyProperty { get; set; }
However, I now need it to perform some action every time it changes, so I want to add logic to the setter. So I ...
8
votes
2
answers
1k
views
Read-Only Auto-Property for Simple Types: Initializer VS Expression Body Getter
In C# 6.0, the new syntax let us write read-only auto-properties with using an initializer:
public bool AllowsDuplicates { get; } = true;
Likewise, we can write it using an expression body getter:
...
1
vote
0
answers
188
views
How do I change an auto-implemented property to use a private member variable while keeping the table/column association unchanged?
I want to change a C# class member from being an auto-implemented property (auto-property?) to use a private member variable instead, in my Windows Phone C#-based app. The change is simple except that ...
0
votes
3
answers
87
views
MATLAB how to automatically read a number of files
I would like to plot a number of 3D graphs from different data files. For example I am using
fid = fopen('SS 1.dat','r');
to read the first file and then plot a graph. How to set the program to ...
0
votes
5
answers
77
views
Automatic properties
I want to know that when you create an Automatic property
and invoke the set in the main() method for a random value , where is that value being stored ?as in this example :
class Program
...
0
votes
0
answers
244
views
Visual Studio 2015 replaces private property with public property
When i have a private field in c#, let's say private string a, which is used in the constructor like this:
a = "1";
Console.WriteLine(a);
and i create a public property via: Ctrl + R + E
Visual ...
13
votes
5
answers
4k
views
C# 6 auto-properties - read once or every time?
I follow a pattern when setting certain properties whereby I check to see if the corresponding field is empty, returning the field if not and setting it if so. I frequently use this for reading ...
13
votes
3
answers
5k
views
F# interfaces and properties
I'm trying to get a grip on F#, and in the process I am converting some C# code. I'm having some trouble with defining properties in an interface and implementing them in a type.
Consider the ...
2
votes
2
answers
1k
views
document.customdocumentproperties not being saved
I have searched high and low on stackexchange and other sites (vbaexpress, MSDN, etc...). There is extensive dialog around this, I have tried most of the examples, and still nothing is working.
...
0
votes
1
answer
5k
views
Tableau automatic parameter / calculated field
I am very new to Tableau, and I am strugling a bit. I have a data set of measurements from an automated process looking similar to this:
| UNC with intial data | ... | Measurement Start | UNC with ...