这听起来很奇怪,但也许存在一个...我用Google搜索,但没有找到任何东西.
简单的例子:
我有一个文件class1.h:
#include "a.h"
#include "b.h"
Run Code Online (Sandbox Code Playgroud)
另一个文件class2.h:
#include "a.h"
#include "c.h"
Run Code Online (Sandbox Code Playgroud)
和main.cpp:
#include "class2.h" //as we see here, we getting "a.h" double included by class1.h and class2.h
Run Code Online (Sandbox Code Playgroud)
我想在我的项目中摆脱这种欺骗.
当然,在例子中并没有那么难,但我有大量的文件,它们在很多方面相互包含,很难自己追踪所有的欺骗.
在我自己编写该工具之前,有什么建议吗?:)
static void Main(string[] args)
{
string str_val = "8584348,894";
//int prefix = Convert.ToInt32(str_val[0]); //prefix = 56 O_o
//int prefix = (int)str_val[0]; //what, again 56? i need 8!
int prefix = Convert.ToInt32("8"); //at least this works -_-
}
Run Code Online (Sandbox Code Playgroud)
知道如何将第一个符号转换为正确的数值?
我从项目设置 - >资源
中将图像添加到我的c#项目中如何在运行时获取此图像?
我试着这个:
public byte[] GetResource(string ResourceName)
{
System.Reflection.Assembly asm = Assembly.GetEntryAssembly();
// list all resources in assembly - for test
string[] names = asm.GetManifestResourceNames(); //even here my TestImg.png is not presented
System.IO.Stream stream = asm.GetManifestResourceStream(ResourceName); //this return null of course
byte[] data = new byte[stream.Length];
stream.Read(data, 0, (int)stream.Length);
return data;
}
Run Code Online (Sandbox Code Playgroud)
我这样称呼这个函数:
byte[] data = GetResource("TestImg.png");
Run Code Online (Sandbox Code Playgroud)
但我在项目浏览器的Resources文件夹中看到了我的图像.

有谁能说出那里有什么问题?

我有这个程序:
#include <Windows.h>
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_CLOSE:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
int main()
{
WNDCLASSA wnd_class = { 0 };
wnd_class.lpfnWndProc = WndProc;
wnd_class.hInstance = GetModuleHandle(NULL);
wnd_class.lpszClassName = "actwnd";
RegisterClassA(&wnd_class);
HWND main_wnd = CreateWindowA(wnd_class.lpszClassName, "Program activation", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, 640, 480, NULL, 0, wnd_class.hInstance, NULL);
MSG msg = { 0 };
while(GetMessage(&msg, NULL, 0, 0) > 0)
{
TranslateMessage(&msg); …Run Code Online (Sandbox Code Playgroud) 我有一个巨大的_query_that_runs_fine_alone以 开头select。
我想将该查询结果插入到现有表中,但通常的 SQL 语句不起作用。
\n\n我尝试过:插入 test_ds.test_tbl (field1, \xe2\x80\xa6, fieldN) 值(巨大_query_that_runs_fine_aloneselect ),但查询编辑器在意想不到的地方告诉我该关键字;
这是: select * into test_ds.test_tbl from ( huge_query_that_runs_fine_alone ),但查询编辑器告诉我这个Syntax error: Unexpected keyword INTO at [1:10];
该怎么办?
\n\nPS 完整查询...
\n\ninsert into test_bq_dataset.test_tbl (Naimenovanie_SKU, Naimenovanie_TT, MonthNo, YearNo, AmountPromo, SumPromo, AmountNoPromo, SumNoPromo) values (select promos.Naimenovanie_SKU, promos.Naimenovanie_TT, promos.MonthNo, promos.YearNo, AmountPromo, SumPromo, AmountNoPromo, SumNoPromo from\n(select Naimenovanie_SKU, Naimenovanie_TT, MonthNo, YearNo, sum(Prodazhi_Litry) as AmountPromo, sum(Prodazhi_Summa_s_NDS) as SumPromo from IACloud0539_Calc.Data2_PROMO where Promo …Run Code Online (Sandbox Code Playgroud) 我测试此代码适用于除Microsoft Edge之外的每个浏览器.
<html>
<head>
<title>test embed</title>
</head>
<body>
<embed autoplay = 'false' type = 'video/mp4' src = 'http://download.wavetlan.com/SVV/Media/HTTP/H264/Talkinghead_Media/H264_test1_Talkinghead_mp4_480x360.mp4' />
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
但是,我无法找到有关此标签支持的任何信息.也许我们需要做一些其他embed工作才能在Edge工作?
Edge女士只显示空白页面.
我不打算用object.
这是我第一次处理 SQL Server 触发器。
在此之前,我为 MySql Server 编写了几乎相同的触发器,现在尝试为 SQL Server 重新编码。我修复了所有东西,但现在不明白它想要什么?我们如何才能像在 MySQL 中那样访问刚刚插入的行的某些列 - NEW.some_field?
CREATE TRIGGER AntiCloneInsert ON dbo.user_item FOR INSERT AS
DECLARE @acc_id INT;
DECLARE @items_count INT;
IF (NEW.item_type in (select item_type from dbo.forbidden_item_types))
BEGIN
select @items_count = count(item_type) from dbo.user_item where item_type = NEW.item_type and warehouse = NEW.warehouse
IF (@items_count > 1)
BEGIN
select @acc_id = account_id from dbo.user_data where char_id = NEW.char_id
update lin2db.dbo.user_account set block_flag2 = 1 where uid = @acc_id
END
END
Run Code Online (Sandbox Code Playgroud)
我尝试创建此触发器但收到此类错误:
消息 …
目前,我编写了客户端-服务器垃圾代码,并处理了大量通过网络传递的 C++ 结构。我知道这里提供的方法从字节数组中读取 C# 中的 C/C++ 数据结构,但它们都是关于制作副本的。
我想要这样的东西:
struct/*or class*/ SomeStruct
{
public uint F1;
public uint F2;
public uint F3;
}
Run Code Online (Sandbox Code Playgroud)
稍后在我的代码中我想要类似的东西:
byte[] Data; //16 bytes that I got from network
SomeStruct PartOfDataAsSomeStruct { get { return /*make SomeStruct instance based on this.Data starting from index 4, without copying it. So when I do PartOfDataAsSomeStruct.F1 = 132465; it also changes bytes 4, 5, 6 and 7 in this.Data.*/; } }
Run Code Online (Sandbox Code Playgroud)
如果可以的话,请问如何实现?
该功能可以将存储块移动到新位置,在这种情况下返回新位置.
例如,我有一个指向数组的指针:
int *arr; // somewhere next it initialized, filled with elements and etc
Run Code Online (Sandbox Code Playgroud)
在某个地方我需要:
void* location = realloc(arr, NEW_SIZE);
Run Code Online (Sandbox Code Playgroud)
旧的内存块会发生什么?
如果realloc返回不是数学的指针到arr,我应该使用下一个代码吗?:
delete arr;
arr = (int*)location;
Run Code Online (Sandbox Code Playgroud) 可能重复:
如何创建多行字符串
在c#中,我可以这样做:
string str = @"asd
dsa
blah blah blah";
Run Code Online (Sandbox Code Playgroud)
我怎样才能在JavaScript中做同样的事情?+每个字符串都是坏主意......
这就是我在条形图上显示的字符串:
public class ProgressBarWithText : ProgressBar
{
const int WmPaint = 15;
SizeF TextSize;
PointF TextPos;
public ProgressBarWithText()
{
this.DoubleBuffered = true;
this.TextChanged += ProgressBarWithText_TextChanged;
this.SizeChanged += ProgressBarWithText_SizeChanged;
}
public override string Text
{
get { return base.Text; }
set { base.Text = value; }
}
void RecalcTextPos()
{
if (string.IsNullOrEmpty(base.Text))
return;
using (var graphics = Graphics.FromHwnd(this.Handle))
{
TextSize = graphics.MeasureString(base.Text, this.Font);
TextPos.X = (this.Width / 2) - (TextSize.Width / 2);
TextPos.Y = (this.Height / 2) - (TextSize.Height / 2); …Run Code Online (Sandbox Code Playgroud) 我经常在类中看到属性,而不是字段。它看起来像这样:
class TestClass
{
public ulong Id { get; set; }
public string Description { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
人们为什么这样做?他们可以改用字段。我在那里至少看到一个专业人士 - 我们可以将带有ref关键字的字段传递给函数。是否有任何专业人士出于财产或其他原因像那样使用它们?
c# ×5
c++ ×3
text ×2
arrays ×1
duplicates ×1
embed ×1
field ×1
flicker ×1
html ×1
include ×1
integer ×1
javascript ×1
marshalling ×1
multiline ×1
mysql ×1
progress-bar ×1
properties ×1
realloc ×1
sql ×1
sql-server ×1
string ×1
struct ×1
winapi ×1
windows ×1