parameters

How to set optional parameter without compile-time constant

泄露秘密 提交于 2019-12-30 07:57:13
问题 Is there a way to write the C# method below: public string Download(Encoding contentEncoding = null) { defaultEncoding = contentEncoding ?? Encoding.UTF8; // codes... } with a default parameter added so it looks like this: public string Download(Encoding contentEncoding = Encoding.UTF8) { // codes... } without using a compile-time constant? 回答1: In short. No. Optional parameters are required to be compile time constants or value types. From Named and Optional Arguments (C# Programming Guide)

Java Servlet/Jsp image upload along with form values [closed]

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-30 07:55:10
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I have a jsp form that accepts details about Employee name, sex, age, E-mail address and a 回答1: Servlet 3.0 container's has standard support for multipart data. First you should be writing a HTML page which takes

Best way to document “splatted” parameter with YARD? [closed]

江枫思渺然 提交于 2019-12-30 06:17:31
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed last year . I have a method that should take 1+ parameters of any class, similar to Array#push: def my_push(*objects) raise ArgumentError, 'Needs 1+ arguments' if objects.empty? objects.each do |obj| puts "An object was pushed: #{obj.inspect}" @my_array.push obj end end What is the best

Naming convention for class properties in TypeScript

无人久伴 提交于 2019-12-30 05:55:08
问题 According to the offical style guide you should Avoid prefixing private properties and methods with an underscore. As I come from a Java background, I usually would just use the this keyword: export default class Device { private id: string; constructor(id: string) { this.id = id; } public get id(): string { // [ts] Duplicate identifier 'id'. return this.id; } public set id(value: string) { // [ts] Duplicate identifier 'id'. this.id = value; } } But the TypeScript compiler complains: [ts]

How to use a PowerShell variable as command parameter?

被刻印的时光 ゝ 提交于 2019-12-30 04:00:12
问题 I'm trying to use a variable as a command's parameter but can't quite figure it out. Let's say MyCommand will accept two parameters: option1 and option2 and they accept boolean values. How would I use $newVar to substitute option 1 or 2? For example: $newVar = "option1" MyCommand -$newVar:$true I keep getting something along the lines of 'A positional parameter cannot be found that accepts argument '-System.String option1' . More Specifically: Here, the CSV file is an output of a different

SSRS date default with formula disables parameter

℡╲_俬逩灬. 提交于 2019-12-30 03:55:08
问题 When I set a default value formula for a date parameter in SSRS, such as: =CDate(”01/” & Month(Now) & “/” & Year(Now)) or even: =Now the date parameter control becomes disabled with nothing in it. Does anyone know what simple thing (I am sure) I am doing wrong? 回答1: After playing some more, I realized that the date controls became enabled when I picked a value from a preceding dropdown parameter that did not have a default. Apparently, controls after non-default parameters are disabled until

Swift/iOS: How to use inout parameters in functions with AnyObject/Any or Pointers

假如想象 提交于 2019-12-30 02:21:31
问题 I'm trying to write a function that takes a variable pointer and a descriptor/key and sets a new value for the variable. Ideally the pointer should be either of an object or a primitive, but I could also live with separate functions (or an additional parameter). In my code I retrieve the new value from a database also using the key, but in the following example I simplified it with dummy values so that it can be used easily in a playground: import UIKit func setValue(inout object: AnyObject,

powershell sending multiple parameter to a external command

感情迁移 提交于 2019-12-30 01:56:05
问题 I am trying to run a external exe from a powershell script. This exe wants 4 parameters. I have been trying every combo of invoke-item, invoke-command, & 'C:\program files\mycmd.exe myparam', made a shortcut in C:\ to get rid of the spaces in the path. I can make it work with one parameter, but not with more. I get various errors. To sum up, how do you send 4 parameters to an exe? 回答1: It's best if shown in longhand. Once you see what's going on, you can shorten it down by just using commas

Pass array to ParamArray

…衆ロ難τιáo~ 提交于 2019-12-30 01:53:20
问题 is it possible to pass all elements of an array to a ParamArray? For example I'd like to pass a ParamArray to another ParamArray: Sub test() p1 "test", "banane", "birne" End Sub Sub p1(ParamArray keys() As Variant) p2 keys 'should be the same as: p2 "test", "banane", "birne" End Sub Sub p2(ParamArray keys() As Variant) Dim key As Variant For Each key In keys Debug.Print key 'Run-time error '13' Type mismatch (key is an array) Next key End Sub In this case ParamArray of p2 doesn't contain the

Java: Enum parameter in method

淺唱寂寞╮ 提交于 2019-12-30 00:53:07
问题 I have a method lets say: private static String drawCellValue( int maxCellLength, String cellValue, String align) { } and as you can notice, I have a parameter called align. Inside this method I'm going to have some if condition on whether the value is a 'left' or 'right'.. setting the parameter as String, obviously I can pass any string value.. I would like to know if it's possible to have an Enum value as a method parameter, and if so, how? Just in case someone thinks about this; I thought