default-value

How can I change the default value of an inherited dependency property?

时光毁灭记忆、已成空白 提交于 2019-11-26 16:27:02
问题 How can I change the default value for an inherited dependency property? In our case, we've created a subclass of Control which by default has its Focusable set to 'true'. We want our subclass to have the default of 'false'. What we've been doing is simply setting it to 'false' in the constructor, but if someone uses ClearValue, it goes back to the default, not the value set in the constructor. Here's what I'm currently doing to achieve this (This is a test control with a DP of 'Foo' for an

Passing an empty array as default value of an optional parameter [duplicate]

坚强是说给别人听的谎言 提交于 2019-11-26 15:25:47
This question already has an answer here: Setting the default value of a C# Optional Parameter 3 answers How does one define a function that takes an optional array with an empty array as default? public void DoSomething(int index, ushort[] array = new ushort[] {}, bool thirdParam = true) results in: Default parameter value for 'array' must be a compile-time constant. You can't create compile-time constants of object references. The only valid compile-time constant you can use is null , so change your code to this: public void DoSomething(int index, ushort[] array = null, bool thirdParam =

Change default text in input type=“file”?

∥☆過路亽.° 提交于 2019-11-26 15:05:39
I want to change default text on button that is " Choose File " when we use input="file" . How can I do this? Also as you can see in image button is on left side of text. How can I put it on right side of text? Shiv Kumar Each browser has it's own rendition of the control and as such you can't change either the text or the orientation of the control. There are some "kind of" hacks you may want to try if you want an html / css solution rather than a Flash or silverlight solution. http://www.quirksmode.org/dom/inputfile.html http://www.shauninman.com/archive/2007/09/10/styling_file_inputs_with

python - returning a default value

我是研究僧i 提交于 2019-11-26 14:36:51
问题 I'm looking to mimic the behavior of built-in functions (like getattr ) that allow the user to specify a "default" return value. My initial attempt was to do this def myfunc(foo, default=None): # do stuff if (default is not None): return default raise SomeException() The problem is that if the users wants None to be their return value, this function would instead raise an exception. second attempt: def myfunc(foo, **kwargs): # do stuff if ('default' in kwargs): return kwargs['default'] raise

Creating (and Accessing) a Sparse Matrix with NA default entries

别等时光非礼了梦想. 提交于 2019-11-26 13:46:08
问题 After learning about the options for working with sparse matrices in R, I want to use the Matrix package to create a sparse matrix from the following data frame and have all other elements be NA . s r d 1 1089 3772 1 2 1109 190 1 3 1109 2460 1 4 1109 3071 2 5 1109 3618 1 6 1109 38 7 I know I can create a sparse matrix with the following, accessing elements as usual: > library(Matrix) > Y <- sparseMatrix(s,r,x=d) > Y[1089,3772] [1] 1 > Y[1,1] [1] 0 but if I want to have the default value to be

Is it possible to have a default parameter for a mysql stored procedure?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 12:41:08
问题 I have googled this and keep coming up with \"No it is not possible\" but these posts were dated 2005-2007 so I\'m wondering if this has been changed. A code example: CREATE PROCEDURE `blah` ( myDefaultParam int = 0 -- This breaks the code for some reason ) BEGIN -- Do something here END One of the solutions has been to pass null and then check for null and set the variable. I don\'t want to do that and I shouldn\'t have to. If this is true then MySql devs need to wake up because there is so

How to populate/instantiate a C# array with a single value?

无人久伴 提交于 2019-11-26 12:13:38
I know that instantiated arrays of value types in C# are automatically populated with the default value of the type (e.g. false for bool, 0 for int, etc.). Is there a way to auto-populate an array with a seed value that's not the default? Either on creation or a built-in method afterwards (like Java's Arrays.fill() )? Say I wanted an boolean array that was true by default, instead of false. Is there a built-in way to do this, or do you just have to iterate through the array with a for loop? // Example pseudo-code: bool[] abValues = new[1000000]; Array.Populate(abValues, true); // Currently how

Unknown file type MIME?

拜拜、爱过 提交于 2019-11-26 12:07:46
问题 Do I have to specify a MIME type if the uploaded file has no extension? In other words is there a default general MIME type? 回答1: You can use application/octet-stream for unknown types. RFC 2046 states in section 4.5.1: The "octet-stream" subtype is used to indicate that a body contains arbitrary binary data. 回答2: RFC resources: We should use RFC-7231 (HTTP/1.1 Semantics and Content) as reference instead of RFC-2046 (Media Types) because question was clearly about HTTP Content-Type. Also RFC

How to set a default value for an existing column

狂风中的少年 提交于 2019-11-26 12:03:10
This isn't working in SQL Server 2008: ALTER TABLE Employee ALTER COLUMN CityBorn SET DEFAULT 'SANDNES' The error is: Incorrect syntax near the keyword 'SET'. What am I doing wrong? This will work in SQL Server: ALTER TABLE Employee ADD CONSTRAINT DF_SomeName DEFAULT N'SANDNES' FOR CityBorn; ALTER TABLE Employee ADD DEFAULT 'SANDNES' FOR CityBorn cannot use alter column for that, use add instead ALTER TABLE Employee ADD DEFAULT('SANDNES') FOR CityBorn user3310402 The correct way to do this is as follows: Run the command: sp_help [table name] Copy the name of the CONSTRAINT . Drop the DEFAULT

Default value to a parameter while passing by reference in C++

喜夏-厌秋 提交于 2019-11-26 11:15:38
Is it possible to give a default value to a parameter of a function while we are passing the parameter by reference. in C++ For example, when I try to declare a function like: virtual const ULONG Write(ULONG &State = 0, bool sequence = true); When I do this it gives an error: error C2440: 'default argument' : cannot convert from 'const int' to 'unsigned long &' A reference that is not to 'const' cannot be bound to a non-lvalue You can do it for a const reference, but not for a non-const one. This is because C++ does not allow a temporary (the default value in this case) to be bound to non