value-type

MATLAB variable passing and lazy assignment

自作多情 提交于 2020-01-01 12:07:55
问题 I know that in Matlab, there is a 'lazy' evaluation when a new variable is assigned to an existing one. Such as: array1 = ones(1,1e8); array2 = array1; The value of array1 won't be copied to array2 unless the element of array2 is modified. From this I supposed that all the variables in Matlab are actually value-type and are all passed by values (although lazy evaluation is used). This also implies that the variables are created on the call stack. Well, I am not judging the way it treats the

In C# are the terms “Primitive” and “Literal” interchangeable?

时光毁灭记忆、已成空白 提交于 2020-01-01 02:15:13
问题 A discussion earlier today led me to question whether or not my understanding of primtives and literals is correct. My understanding is that a literal type is specifically a type which can have a value assigned using a notation that both human and compiler can understand without specific type declarations: var firstName = "John"; // "John" is literal var firstName = (string)"John"; // *if* the compiler didn't understand that "John" // was a literal representation of a string then I // would

Using NHibernate ICompositeUserType with a value type

拟墨画扇 提交于 2019-12-30 08:15:23
问题 I have a domain model object which has properties of type System.DateTimeOffset. I'm using a database which doesn't support this type natively, so I'm planning to store it using a column of type 'datetime' and one of type 'smallint'. I've dug around on how to map this using NHibernate components, and found that it could work using an ICompositeUserType instance. However, upon implementing the interface, I've come across the method called "SetPropertyValue" which ostensibly sets a property

Why value types can't be null

强颜欢笑 提交于 2019-12-29 05:45:10
问题 I know that it is possible to have Nullable value types that wraps the value type and gives ability to store null. But is there a technical reason do not allow the value type to be null or the reason is only conceptual? 回答1: A reference type is storeed as a reference (like a pointer) to an object instance. null means a reference that isn't pointing to an instance of an object. Value types are stored as the values themselves, without any references. Therefore, it doesn't make sense to have a

Why can't I assign List<int> to IEnumerable<object> in .NET 4.0

元气小坏坏 提交于 2019-12-28 20:37:32
问题 I try to do this: IEnumerable<object> ids = new List<string>() { "0001", "0002", "0003" }; it works great! But when I try to do this: IEnumerable<object> intIds = new List<System.Int32>() { 1, 2, 3 }; Visual Studio tells me: Cannot implicitly convert type 'System.Collections.Generic.List' to 'System.Collections.Generic.IEnumerable'. An explicit conversion exists (are you missing a cast?) Why is that? 回答1: int is a value type and can only be boxed to object - it doesn't inherit from object .

Reference cycles with value types?

给你一囗甜甜゛ 提交于 2019-12-28 04:08:10
问题 Reference cycles in Swift occur when properties of reference types have strong ownership of each other (or with closures). Is there, however, a possibility of having reference cycles with value types only ? I tried this in playground without succes ( Error: Recursive value type 'A' is not allowed ). struct A { var otherA: A? = nil init() { otherA = A() } } 回答1: A reference cycle (or retain cycle ) is so named because it indicates a cycle in the object graph: Each arrow indicates one object

C# Class as one Value in Class // Mimic int behaviour

北城以北 提交于 2019-12-25 19:10:43
问题 Is there a way to make my new Class mimic the behavior of an int or any Valuetype? I want something, so these assignments are valid MyClass myClass = 1; int i = myClass; var x = myClass; // And here is important that x is of type int! The MyClass looks roughly like this public class MyClass { public int Value{get;set;} public int AnotherValue{get;set;} public T GetSomething<T>() {..} } Every assignment of MyClass should return the Variable Value as Type int. So far i found implicit operator

How to declare a const field of a generic value type provided as generic argument

好久不见. 提交于 2019-12-24 14:45:27
问题 I'm trying to define a generic class that accept as argument a value type (actually it will be an enum) and initialize a const field with it's default type. I want something like: public abstract class GenericClass<ValueType> where ValueType: struct, IConvertible { public const ValueType val = default(ValueType); } Unfortunately the compiler complaints (I'm using Mono but I think it's the same on .NET). The error is the following: error CS1959: Type parameter `ValueType' cannot be declared

Value type error SWIFT/XCODE

人盡茶涼 提交于 2019-12-24 11:27:05
问题 I have a table view where i want the view controller to pop instead of segue when the cell is selected although I am getting this error "Value of type 'UINavigationController' has no member 'popViewController'"-- Any ideas??? Please note: I am using swift 2 and xcode7 回答1: I think in swift 2 and Xcode 7 the function is: navigationController?.popViewControllerAnimated(true) 来源: https://stackoverflow.com/questions/40319160/value-type-error-swift-xcode

INotifyPropertyChanged issue, property is not being updated from Dispatcher

混江龙づ霸主 提交于 2019-12-24 05:56:40
问题 I have an issue with some of my properties not being updated when I use a Dispatcher from a separate thread. When I check for values in the array, they're all 0's. Properties: private string[] _years; public string[] Years { get { return _years; } private set { if (_years == value) { return; } _years = value; OnPropertyChanged("Years"); } } private int[] _yearCounts; public int[] YearCounts { get { return _yearCounts; } private set { if (_yearCounts == value) { return; } _yearCounts = value;