我有一个描绘人数的条形图.当只有少数人时,Y轴显示值:0.5,1,1.5等......看起来有点傻.
AxisY.LabelStyle.Interval = 1
),但是如果有100个人则不起作用AxisY.Maximum = 10
,但这不适用于100人AxisY.LabelStyle.Format = {#}
,但是它会显示[1,1,2,2],因为它会对每个标签进行舍入我意识到我可以根据内容动态地利用前两个选项中的任何一个,但想知道是否有一种自动方式使标签"仅整数"?
private Result Execute(
out T returnValue,
string storedProcedureName,
Hashtable parameters,
ExecuteType executeType)
where T : class
Run Code Online (Sandbox Code Playgroud)
以下错误意味着什么,我该如何解决?
错误在何处:非泛型声明中不允许约束
我已经尝试了两个Theme.DeviceDefault
和Theme.Black
我的styles.xml,并且都使我的2.1模拟器变得正确,但在4.1模拟器上它保持白色......我做错了什么?
<resources>
<style name="AppTheme" parent="android:Theme.Black" />
</resources>
Run Code Online (Sandbox Code Playgroud)
PS:我认为图形布局顶部的"主题"下拉菜单只是向我展示了它的外观,它不是某种设置(适用于应用程序)?
例如,我想这样做,但它会产生一个错误:
<Chain>
<MsiPackage SourceFile="$(var.SetupProjectWiX.TargetPath)" />
</Chain>
Run Code Online (Sandbox Code Playgroud)
- SetupProjectWiX
我的MSI WiX项目在哪里.
我在创建MSI时做了类似的事情,并认为上面的内容是可行的.这是引用VS项目的MSI创建
<File Source="$(var.uCamera.TargetPath)" />
Run Code Online (Sandbox Code Playgroud)
编辑:
我没有在引导程序项目中添加MSI项目作为参考 - 现在它就像一个魅力:-)
这会覆盖我的字符串的内容:
unsafe
{
fixed (char* chars = str)
{
for (int i = 0; i < str.Length; i++)
chars[i] = '1';
}
}
Run Code Online (Sandbox Code Playgroud)
背景是我正在使用NetworkCredientials,您可以使用普通旧密码设置密码System.String
.如果可能的话,之后我想"清除它".关于如何做到这一点的任何建议都是受欢迎的,但主要的问题是要了解是否fixed
真的能让我访问底层的char数组.谢谢!
编辑
我想了解什么是怎么回事-如果一个字符串对象是不可变的,并且fixed
不会让那么物体移动所发生的事情中的代码发布?这些字符写在哪里?
我有一个存储过程,我想授予插入标识的权限,同时不给予受限用户调用ALTER TABLE权限.那可能吗?
这是我的存储过程:
CREATE PROCEDURE [dbo].[AddInternalQu]
(
@id [int],
@qu [nvarchar](500),
@pg [nvarchar](50),
@isactive [bit],
@isdoc [bit],
@allowNA [bit],
@textBox [bit],
@redf [bit],
@qord [int],
@shqu [nvarchar](50),
@restrict [bit],
@scanwizard [bit]
)
AS
BEGIN
SET IDENTITY_INSERT [questions] ON;
INSERT INTO [questions] (qu_id, question, shortqu, redflag, page, active, is_doc_qu,
allowNA, textBox, qu_order, scanwizard, restricted)
VALUES(@id, @qu, @shqu, @redf, @pg, @isactive, @isdoc,
@allowNA, @textBox, @qord, @scanwizard, @restrict);
SET IDENTITY_INSERT [questions] OFF;
END
GRANT EXEC ON AddInternalQu TO MyStandardRole;
Run Code Online (Sandbox Code Playgroud)
因为它是一个用户,我添加到该MyStandardRole
角色有权执行存储过程,但后来尝试设置没有足够权限的身份插入失败.
这是基于此问题的代码的示例(尽管是针对序列化)。是否可以覆盖所有Required.Always
属性Required.Default
(即“可选”),并允许我反序列化对象,而不管“必需”属性如何?
public class OverrideToDefaultContractResolver : DefaultContractResolver
{
protected override JsonObjectContract CreateObjectContract(Type objectType)
{
var contract = base.CreateObjectContract(objectType);
contract.ItemRequired = Required.Default;
return contract;
}
}
public class MyClass
{
[JsonProperty("MyRequiredProperty", Required = Required.Always, NullValueHandling = NullValueHandling.Ignore)]
public string MyRequiredProperty { get; set; }
}
public static void Test()
{
var settings = new JsonSerializerSettings { ContractResolver = new OverrideToDefaultContractResolver() };
MyClass obj = JsonConvert.DeserializeObject<MyClass>(@"{""Nope"": ""Hi there""}", settings);
Console.WriteLine($"Json property: {obj.MyRequiredProperty}");
}
Run Code Online (Sandbox Code Playgroud) 我希望能够更改自定义的绑定属性ViewCell
并更新该ListView
项目 - 但它似乎仅用于初始化视图并且不会反映更改。请告诉我我缺少什么!
在这里,我选择了点击事件并尝试更改 ViewCell 的字符串,但没有成功:
private void DocChooser_ItemTapped(object sender, ItemTappedEventArgs e)
{
var tappedItem = e.Item as DocumentChooserList.DocumentType;
tappedItem.Name = "Tapped"; // How can I change what a cell displays here? - this doesn't work
}
Run Code Online (Sandbox Code Playgroud)
这是我的 ViewCell 代码:
class DocumentCellView : ViewCell
{
public DocumentCellView()
{
var OuterStack = new StackLayout()
{
Orientation = StackOrientation.Horizontal,
HorizontalOptions = LayoutOptions.FillAndExpand,
};
Label MainLabel;
OuterStack.Children.Add(MainLabel = new Label() { FontSize = 18 });
MainLabel.SetBinding(Label.TextProperty, "Name");
this.View = …
Run Code Online (Sandbox Code Playgroud) 我有这个行过滤器文本:"[Name 1] = '" + forename + "%" + surname + "'"
失败,但如果我把它%
放在开头或结束它没关系.有没有办法实现相同的结果(即名称中间的"任何"字符串)?
完整声明是:
dv = new DataView(MyDataTable,
"[Name 1] = '" + forename + "%" + surname + "'",
"", DataViewRowState.CurrentRows);
Run Code Online (Sandbox Code Playgroud) 例如,给定此代码:
int? ReallyComplexFunction()
{
return 2; // Imagine this did something that took a while
}
void Something()
{
int i = ReallyCleverFunction() ?? 42;
}
Run Code Online (Sandbox Code Playgroud)
...是否保证只调用一次该函数?在我的测试中,它只被调用一次,但是我看不到任何文档说明我可以依赖它总是如此.
编辑
我猜它是如何实现的,但来吧:我们是开发人员.我们不应该在猜测和假设上混淆.例如,将来所有的实现都是一样的吗?另一个平台的语言实现是否相同?这取决于语言的规格以及它提供的保证.例如,未来或不同的平台实现(不是一个好的,但它可能)可以在??
实现中执行此操作:
return ReallyComplexFunction() == null ? 42 : ReallyComplexFunction();
Run Code Online (Sandbox Code Playgroud)
ReallyComplexFunction
如果它没有返回,那将会调用两次null
.(虽然这看起来可笑的实现,如果你有一个可为空的变量替换功能,它看起来相当合理:return a == null ? 42 : a
)
如上所述,我知道在我的测试中它只被调用一次,但我的问题是C#规范是否保证/指定左侧只调用一次?如果是的话,在哪里?我在C#语言规范中看不出任何这样的提及?运算符(我最初寻找我的查询的答案).
我只是在 Azure WebApplication 网站上使用 Arial 字体,但是当我到达这一行时:
MainFont = new XFont("Arial", FontSize);
Run Code Online (Sandbox Code Playgroud)
它抛出一个异常读数: Font data could not retrieved.
我原以为 Arial 会安装在服务器上……我还尝试将其更改为 Sans-Serif 以匹配 Microsoft 生成的网站的默认字体……但它仍然失败。
我也尝试将 Arial.ttf 添加到项目中,但没有奏效。
如果我也杀死了应用程序实例,我想在后台运行我的应用程序。但是在我杀死我的应用程序后,该服务也停止工作。这是我的代码,请任何人帮助我解决我的问题。
我按照此链接在后台运行,但如果我删除实例,它就不起作用。如果实例也被删除,请任何人告诉我如何运行后台服务?
这是我的主要活动
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ctx = this;
setContentView(R.layout.activity_main);
Intent alarmIntent = new Intent(MainActivity.this, AlarmReceiver.class);
pendingIntent = PendingIntent.getBroadcast(MainActivity.this, ALARM_REQUEST_CODE, alarmIntent, 0);
mSensorService = new SensorService(getCtx());
mServiceIntent = new Intent(getCtx(), mSensorService.getClass());
if (!isMyServiceRunning(mSensorService.getClass())) {
startService(mServiceIntent);
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的服务类
public class SensorService extends Service{
public int counter=0;
public SensorService(Context applicationContext) {
super();
Log.i("HERE", "here I am!");
}
public SensorService() {
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
super.onStartCommand(intent, flags, startId);
startTimer();
return START_STICKY; …
Run Code Online (Sandbox Code Playgroud) 在C#中使用SQL Server值得说:
IF COL_LENGTH('MyTable','MyColumn') IS NULL
BEGIN
ALTER TABLE MyTable ADD MyColumn INT
END
Run Code Online (Sandbox Code Playgroud)
因为我可以更容易地抓住电话:
try
{
Db.ExecuteNonQuery("ALTER TABLE MyTable ADD MyColumn INT");
}
catch(Exception)
{
}
Run Code Online (Sandbox Code Playgroud)
如果一直失败(除了在旧数据库上运行时),或者只是那个顽皮/慢/等?