default-value

Abstract class with default value

我与影子孤独终老i 提交于 2019-12-23 06:51:12
问题 I am trying to define a abstract Range class which will serve as the base implementation of a number of range classes. The intended use is irrelevant for this question, but so far I have: /** * Abstract generic utility class for handling ranges */ public abstract class Range<T extends Number> { // Variables to hold the range configuration private T start; private T stop; private T step; /** * Constructs a range by defining it's limits and step size. * * @param start The beginning of the range

How do I tell Entity Framework to allow SQL Server to provide a defined default value for a field?

拥有回忆 提交于 2019-12-23 06:41:39
问题 I used the following SQL script to enable setting current time in a field, when a new row is added to a table: ALTER TABLE [Items] ADD CONSTRAINT DF_Items DEFAULT GETDATE() FOR [CreationDate] Now I am using Entity Framework to work with this table, and add new rows to it. What I want to do is allow that specific column to receive its value from SQL Server itself, and not have to provide the value myself. Setting that specific column's value to Nothing in Visual Basic fills the field with

C#: Should the default value of an enum be None or Unknown?

萝らか妹 提交于 2019-12-22 04:31:15
问题 Say you have an enum that represents an error code. There will be several codes, each with their own underlying int value; however, the enum value that gets the default 0 value seems like it should be carefully considered. In the case of an error code enum, there are two special values that I can think of: None (for cases when there is no error) and Unknown (for cases when no existing error code is appropriate, or perhaps even when error state cannot be detected). One of these values seems

Set highcharts y-axis min value to 0, unless there is negative data

隐身守侯 提交于 2019-12-22 01:53:22
问题 I'm having an issue with highcharts where I have a number of different charts being generated by JSON calls. For the majority of these charts I need the minimum y-axis value to be set at 0, however there are a couple of occasions where negative values need to be shown. How can I tell highcharts to have a minimum y-axis value of 0 only if there are no negative values in the data, is this even possible? Thanks 回答1: The option that you're looking for is called softMin and was introduced in

Cannot assign a default value to a local variable in SQL

强颜欢笑 提交于 2019-12-22 01:37:38
问题 I am trying to declare local variable like: DECLARE @thresholdDate DATETIME = '2014-11-30' And I am getting error: Cannot assign a default value to a local variable. As per documentation: DECLARE @find varchar(30); /* Also allowed: DECLARE @find varchar(30) = 'Man%'; */ What I am doing wrong? 回答1: Prior to SQL Server 2008, assigning a default value (or initial value) to a local variable is not allowed; otherwise this error message will be encountered. Solution 1: (Use SET ) DECLARE

Why does using a default-valued Java Integer result in a NullPointerException?

﹥>﹥吖頭↗ 提交于 2019-12-21 06:58:26
问题 I am new to Java. I just read that class variables in Java have default value. I tried the following program and was expecting to get the output as 0 , which is the default value on an integer, but I get the NullPointerException . What am I missing? class Test{ static Integer iVar; public static void main(String...args) { System.out.println(iVar.intValue()); } } 回答1: You are right, uninitialized class variables in Java have default value assigned to them. Integer type in Java are not same as

Can I specify a default Color parameter in C# 4.0?

偶尔善良 提交于 2019-12-20 17:32:38
问题 Here is an example function: public void DrawSquare(int x, int y, Color boxColor = Color.Black) { //Code to draw the square goes here } The compiler keeps giving me the error: Default parameter value for 'boxColor'must be a compile-time constant I have tried Color.Black, Color.FromKnownColor(KnownColor.Black), and Color.FromArgb(0, 0, 0) How do I make Color.Black be the default color? Also, I do not want to use a string Black to specify it (which I know would work). I want the Color.Black

Can I specify a default Color parameter in C# 4.0?

你说的曾经没有我的故事 提交于 2019-12-20 17:31:28
问题 Here is an example function: public void DrawSquare(int x, int y, Color boxColor = Color.Black) { //Code to draw the square goes here } The compiler keeps giving me the error: Default parameter value for 'boxColor'must be a compile-time constant I have tried Color.Black, Color.FromKnownColor(KnownColor.Black), and Color.FromArgb(0, 0, 0) How do I make Color.Black be the default color? Also, I do not want to use a string Black to specify it (which I know would work). I want the Color.Black

MySQL - Set default value for field as a string concatenation function

北战南征 提交于 2019-12-20 12:34:16
问题 I have a table that looks a bit like this actors(forename, surname, stage_name); I want to update stage_name to have a default value of forename." ".surname So that insert into actors(forename, surname) values ('Stack', 'Overflow'); would produce the record 'Stack' 'Overflow' 'Stack Overflow' Is this possible? Thanks :) 回答1: MySQL does not support computed columns or expressions in the DEFAULT option of a column definition. You can do this in a trigger (MySQL 5.0 or greater required): CREATE

Why does Scala language require you initialize a instance variable instead of relying on a default value?

◇◆丶佛笑我妖孽 提交于 2019-12-20 09:48:55
问题 Scala language requires you initialize your instance variable before using it. However, Scala does not provide a default value for your variable. Instead, you have to set up its value manually by using the wildcard underscore, which acts like a default value, as follows var name:String = _ I know, i know... I can define a constructor in the class definition, which takes as parameter our instance variable, so Scala does not force its initialization as shown below class Person(var name:String)