nullable Questions

4

Solved

I have a list: List<int, SomeStruct> For some reason, it is not allowing me to assign null values to it. What do I do if I want to have no struct associated?
Korman asked 10/11, 2010 at 20:36

2

Solved

In the code below: void Main() { DateTime cleanDate = DateTime.Now.ToCleanDateTime(); DateTime? nullableCleanDate = DateTime.Now; nullableCleanDate = nullableCleanDate.ToCleanDateTime(); cle...
Guise asked 28/5, 2015 at 18:33

1

Solved

In Spark, literal columns, when added, are not nullable: from pyspark.sql import SparkSession, functions as F spark = SparkSession.builder.getOrCreate() df = spark.createDataFrame([(1,)], ['c1']) ...
Putdown asked 29/7, 2021 at 14:56

3

Solved

As I learn new components in Kotlin, I came accross requireNotNull and checkNotNull but the only difference I've found is that requireNotNull can throw an IllegalArgumentException while checkNotNul...
Inhospitality asked 25/7, 2021 at 18:28

4

Solved

If I have a nullable type Xyz?, I want to reference it or convert it to a non-nullable type Xyz. What is the idiomatic way of doing so in Kotlin? For example, this code is in error: val something:...
Deliciadelicious asked 28/12, 2015 at 18:13

3

Solved

I have a class i want to change the properties of in the editor. So i made my class System.Serializable and made the variables public that i want to be able to change. Like so: [System.Serializab...
Ulric asked 17/10, 2018 at 11:45

9

Solved

I use the "bool" type for variables as I was used to in C++, and I try to put the values of functions or properties I expect to be boolean into my variable. However I often encounter cases where th...
Gran asked 25/7, 2009 at 7:34

2

I have just enabled null checking in my .net core 3.1 project. The problem is that I have a response class public class DecryptResponse { public DecryptStatus Status { get; set; } //This is t...
Dopester asked 28/5, 2020 at 13:25

6

Solved

I am trying to serialize a class several of the data-members are Nullable objects, here is a example [XmlAttribute("AccountExpirationDate")] public Nullable<DateTime> AccountExpirat...
Lumpkin asked 15/1, 2010 at 19:32

4

Solved

Let's say I have this: PriorityType? priority; string userInput = ...; I cannot change how this is defined: PriorityType? priority because it's actually part of a contract with another piece of ...
Spooky asked 23/10, 2015 at 20:52

7

Solved

Quoting from an answer from this question. Guid is a value type, so a variable of type Guid can't be null to start with. What then if I see this? public Nullable<System.Guid> SomePrope...
Toxinantitoxin asked 17/7, 2013 at 7:49

20

How do I convert a nullable int to an int? Suppose I have 2 type of int as below: int? v1; int v2; I want to assign v1's value to v2. v2 = v1; will cause an error. How do I convert v1 to v2?
Sundae asked 13/5, 2011 at 16:59

2

Solved

I need to determine if a generic type is a String, bool, int, double or another class at runtime. I didn't found a way to do it for nullable types: class Foo<T> { void foo() { if (T == int...
Eyre asked 8/5, 2021 at 9:35

3

Solved

num should be nullable when set, but what it returns should always be non-nullable (have a default value). class Test { var num: Int? = null get() = field ?: 5 // default value if null } The f...
Inlay asked 6/10, 2017 at 13:9

7

Solved

I have some C# code with the following array declaration. Note the single ? after Color. private Color?[,] scratch; In my investigating I have found that if you you have code such as: int? a; ...
Lumbricoid asked 27/5, 2013 at 13:5

9

Solved

So, I asked a question this morning, which I did not phrase correctly, so I got a lot of responses as to why NULL compared to anything will give NULL/FALSE. My actual question was, what is the ti...
Cyprinodont asked 2/12, 2009 at 20:23

3

Solved

Problem What is the idiomatic way of working around this limitation of the null-safety in the Kotlin type system? val strs1:List<String?> = listOf("hello", null, "world") ...
Ayeshaayin asked 22/7, 2016 at 21:28

1

Solved

Supposing I have a class like this: public class BridgeFormModel { [Required] [Display( Name = "What is your name?" )] public String? Name { get; set; } [Required] [Display( Name = ...
Merissa asked 20/3, 2021 at 21:53

19

Solved

My model has a boolean that has to be nullable public bool? Foo { get; set; } so in my Razor cshtml I have @Html.CheckBoxFor(m => m.Foo) except that doesn't work. Neither does casting it...
Torrez asked 27/7, 2011 at 19:2

3

Solved

Is it possible to make the following code to compile in Kotlin? val variable: String? = "string" val (a, b) = variable?.run { 1 to 2 }
Landseer asked 4/3, 2020 at 19:27

13

Solved

Java 1.8 is receiving the Optional<T> class, that allows us to explicitly say when a method may return a null value and "force" its consumer to verify if it is not null (isPresent()...
Neutralism asked 24/4, 2013 at 18:9

2

Solved

This program has two errors: using System; T? f<T>(T? t) { t = null; // Error CS0403 Cannot convert null to type parameter 'T' because it could be a non-nullable value type return default...
Longshoreman asked 17/1, 2021 at 20:5

4

Solved

Can someone give me a list, or point me to where I can find a list of C# data types that can be a nullable type? For example: I know that Nullable<int> is ok I know that Nullable<byte[...
Blockus asked 14/5, 2010 at 12:59

4

Solved

Take a look at this kotlin one liner: val nonNullArr : List<NonNullType> = nullArray.filter {it != null} The compiler gives a type error at this line, saying that a list of nullables can't...
Morganica asked 15/2, 2019 at 13:20

2

I have the following DropDownList in an ASP.NET MVC cshtml page: @Html.DropDownListFor(model => model.GroupId, (IEnumerable<SelectListItem>)ViewBag.PossibleGroups, "") The property is d...
Protecting asked 4/3, 2014 at 21:23

© 2022 - 2024 — McMap. All rights reserved.