default

Prevent Visual Studio from adding default references and usings for new classes

丶灬走出姿态 提交于 2019-11-28 09:16:32
Whenever I add a new class to a Visual Studio (C#) project, I get the following usings automatically: using System; using System.Collections.Generic; using System.Linq; using System.Text; Additionally, the following DLL references are added if they weren't there already: System.Core System.Data System.Xml I'd like to prevent VS from doing this (except "using System" of course). Does any one know of a way to prevent this from happening? Marc and Brian both have a good idea: create a new custom template that includes only the usings and references I want. With Export Template it's really simple

Default using directives in new C# files

只愿长相守 提交于 2019-11-28 09:05:23
Why does Visual Studio 2008 automatically insert the following using directives into each new C# file I create? using System; using System.Collections.Generic; using System.Text; What's so special about these namespaces? Are these the most frequently used ones? Jon Skeet Yes, they're frequently used, that's all, so MS put them in the Visual Studio templates . Personally I use "sort and remove unused usings" pretty frequently, so they often go away. If you want to remove them, you can amend the "new class" template . EDIT: If you become a fan of "Sort and Remove Unused Using Directives" you

c++ publicly inherited class member cannot be used as default argument

空扰寡人 提交于 2019-11-28 08:56:51
问题 A schematic of my problem... class A { public: // etc. protected: uint num; }; class B : public A { public: void foo(uint x = num); //bad }; gives this error: error: invalid use of non-static data member ‘A::num’ error: from this location Why does this happen, and what can I do to work around this? 回答1: I suspect this happens (based on the complaint about non-staticness) because there is no this pointer for it to use to know which instance of B it should get num from. The Microsoft compiler

Default values on arguments in C functions and function overloading in C

梦想与她 提交于 2019-11-28 08:22:00
Converting a C++ lib to ANSI C and it seems like though ANSI C doesn't support default values for function variables or am I mistaken? What I want is something like int funcName(int foo, bar* = NULL); Also, is function overloading possible in ANSI C? Would need const char* foo_property(foo_t* /* this */, int /* property_number*/); const char* foo_property(foo_t* /* this */, const char* /* key */, int /* iter */); Could of course just name them differently but being used to C++ I kinda used to function overloading. No, Standard C does not support either. Why do you feel you need to convert your

Default array values if key doesn't exist?

一曲冷凌霜 提交于 2019-11-28 07:58:52
If I have an array full of information, is there any way I can a default for values to be returned if the key doesn't exist? function items() { return array( 'one' => array( 'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, ), 'two' => array( 'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, ), 'three' => array( 'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, ), ); } And in my code $items = items(); echo $items['one']['a']; // 1 But can I have a default value to be returned if I give a key that doesn't exist like, $items = items(); echo $items['four']['a']; // DOESN'T EXIST RETURN DEFAULT OF 99 I know this is an old

What is default storage class for global variables?

余生长醉 提交于 2019-11-28 07:35:30
What is default storage class of a global variable? While searching on web I found, some sites say it is static . But, static means internal linkage and the variable can not be available outside the file scope i.e it should not be available to other object files. But, they still can be accessed to other files using declarations like extern int i . And, if I explicitly mention static to global variable then it is not available outside the file scope. Then, what is correct default storage class for the global variables? The default storage duration is static, but default linkage is external. You

How to set default encoding in Python (setdefaultencoding() function does not exist)? [duplicate]

不羁的心 提交于 2019-11-28 07:34:35
Possible Duplicate: Changing default encoding of python? I am reading dive in python and it mentions setting python's default encoding scheme in the XML parsing chapter. The setdefaultencoding is used in python-installed-dir/site-packages/pyanaconda/ sitecustomize.py import sys sys.setdefaultencoding('utf-8') But when I run the script, it raises: AttributeError: 'module' object has no attribute 'setdefaultencoding' How to set the default encoding,anyway? I am using python 2.7 Solution: find the site.py in the python installation. Edit the setencoding function def setencoding(): encoding =

WPF ControlTemplate: How to provide a default value for TemplateBinding?

对着背影说爱祢 提交于 2019-11-28 07:18:29
I am writing a WPF control that subclasses a Button. I then provide a default style in Themes\generic.xaml, that looks like this (simplified): <Style TargetType="{x:Type WPFControls:MyButton}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type WPFControls:MyButton}"> <Button x:Name="PART_Button" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" /> </ControlTemplate> </Setter.Value> </Setter> </Style> I would like the user to have the opportunity to change the control's background, but if he doesn't, I'd like to provide default

stl vector and c++: how to .resize without a default constructor?

妖精的绣舞 提交于 2019-11-28 07:16:11
How do I tell STL, specifically for the method resize() in vector, to initialize objects with a constructor other than default, and with which parameters? For example: class something { int a; something (int value); } std::vector<something> many_things; many_things.resize (20); More generally, how do I force STL to use my constructor when it needs to create objects, and pass parameters to that constructor? In my case adding a default constructor is not an option, and I'd prefer not to use an array of pointers to solve the problem. Use the 2-argument overload: many_things.resize(20, something(5

argparse default option based on another option

你离开我真会死。 提交于 2019-11-28 07:02:30
问题 Suppose I have an argparse python script: import argparse parser = argparse.ArgumentParser() parser.add_argument("--foo", required=True) Now I want to add another option --bar, which would default to appending "_BAR" to whatever was specified by --foo argument. My goal: >>> parser.parse_args(['--foo', 'FOO']) >>> Namespace(foo='FOO', bar="FOO_BAR") AND >>> parser.parse_args(['--foo', 'FOO', '--bar', 'BAR']) >>> Namespace(foo='FOO', bar="BAR") I need something like this: parser.add_argument("-