FMT fmt=new FMT();
public void ReadFmtHeader()
{
fmt.s_Sub_Chunk_ID_1 = reader.ReadBytes(4);
fmt.ui_Sub_Chunk_Size_ID_1 = reader.ReadBytes(4);
fmt.us_Audio_Format = reader.ReadBytes(2);
fmt.us_Num_Channels = reader.ReadBytes(2);
fmt.ui_Sample_Rate = reader.ReadBytes(4);
fmt.ui_Byte_Rate = reader.ReadBytes(4);
fmt.us_Block_Align = reader.ReadBytes(2);
fmt.us_Bits_Per_Sample = reader.ReadBytes(2);
if (Convert.ToInt32(fmt.ui_Sub_Chunk_Size_ID_1) == 18)// Exception thrown on this line
{
// Read any extra values
int fmtExtraSize = reader.ReadInt16();
reader.ReadBytes(fmtExtraSize);
}
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试读取波形文件,然后使用标题信息重新创建它并保存到文件.我不知道是什么问题.任何人都可以帮我吗?
为什么我无法从Derived访问M3方法?Intellisense仅显示基类中的M1和M2.如何将bc的参考从Base类型更改为Refernce Type,以便我可以访问M3方法.
class Program
{
static void Main(string[] args)
{
Base bc = new Derived();
bc.M3():// error
}
}
class Base
{
public void M1()
{
Console.WriteLine("M1 from BASE.");
}
public void M2()
{
Console.WriteLine("M2 from BASE.");
}
}
class Derived : Base
{
public void M3()
{
Console.WriteLine("M3 from DERIVED.");
}
}
Run Code Online (Sandbox Code Playgroud) <Canvas x:Key="myCanvas"
MinHeight="30" MinWidth="30" Clip="F1 M 0,0L 48,0L 48,48L 0,48L 0,0" >
<Path Data="F1M1737.61,7339.85C1720.49,7342.44 1709.83,7334.36 1709.83,7334.36 1701.44,7341.47 1682.84,7340.17 1682.84,7340.17 1682.66,7388.31 1709.83,7397.03 1709.83,7397.03 1741.17,7386.37 1737.61,7339.85 1737.61,7339.85 M1709.54,7386.88C1707.5,7386.88 1705.85,7385.23 1705.85,7383.18 1705.85,7381.14 1707.5,7379.49 1709.54,7379.49 1711.58,7379.49 1713.23,7381.14 1713.23,7383.18 1713.23,7385.23 1711.58,7386.88 1709.54,7386.88 M1712.37,7367.58C1712.37,7367.58 1712.28,7370.72 1710.94,7372.06 1710.94,7372.06 1709.33,7373.48 1707.54,7371.61 1707.54,7371.61 1707.09,7370.31 1706.47,7366.75L1705.48,7352.56 1705.48,7348.72C1705.48,7348.72 1705.59,7345.14 1709.61,7344.51 1709.61,7344.51 1713.36,7344.34 1713.53,7348.27 1713.53,7348.27 1713.98,7352.56 1712.37,7367.58" Stretch="Uniform" Fill="#FFF1A603" Width="26" Height="26" Margin="0,0,0,0" RenderTransformOrigin="0.5,0.5">
<Path.RenderTransform>
<TransformGroup>
<TransformGroup.Children>
<RotateTransform Angle="0" />
<ScaleTransform ScaleX="1" ScaleY="1" />
</TransformGroup.Children>
</TransformGroup>
</Path.RenderTransform>
</Path>
</Canvas>
Run Code Online (Sandbox Code Playgroud)
如何将wpf的Image Source属性设置为canvas而不是image url?
像这样的东西 …
我有一个下面定义的数组类型 -
TYPE INPUT_ARRAY_NUM IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
Run Code Online (Sandbox Code Playgroud)
我已将上述类型的变量定义为 -
temp INPUT_ARRAY_NUM;
Run Code Online (Sandbox Code Playgroud)
用以下值填充它们 -
temp(0) := 1;
temp(1) := 1;
temp(2) := 3;
Run Code Online (Sandbox Code Playgroud)
如何获得不同的值(1,3)?
如何将View属性的类型重写为我的自定义类型。我的CustomGroupListCollectionView类型为Groups属性添加了额外的属性。在运行时,当我观察到View属性的类型为ListCollectionView时,我想将其更改为CustomGroupListCollectionView。
public class CollectionViewSourceCustom : CollectionViewSource
{
public new CustomGroupListCollectionView View { get; set; }
}
public class CustomGroupListCollectionView : ListCollectionView
{
private readonly CustomGroup _allGroup;
public CustomGroupListCollectionView(IList list)
: base(list)
{
_allGroup = new CustomGroup("All");
foreach (var item in list)
{
_allGroup.AddItem(item);
}
}
public override ReadOnlyObservableCollection<object> Groups
{
get
{
var group = new ObservableCollection<object>(base.Groups.ToList());
group.Add(_allGroup);
return new ReadOnlyObservableCollection<object>(group);
}
}
}
public class CustomGroup : CollectionViewGroup
{
public CustomGroup(object name)
: base(name)
{
}
public void AddItem(object …Run Code Online (Sandbox Code Playgroud) 我有一个名为Sample的类,其名称为Name,ToString()的字符串属性被重写以返回Name属性.
然后我创建了两个实例s1和s2,s1初始化,它的Name属性设置为"ABC",s2设置为null.
当我尝试使用??打印值时 对于s2,不打印c#的运算符,值字符串"Null".
class Program
{
static void Main(string[] args)
{
Sample s1 = new Sample();
s1.Name = "ABC";
Sample s2 = null;
Console.WriteLine("Some Sample Name : " + s1 ?? "Null");
Console.WriteLine("Some Sample Name : " + s2 ?? "Null");
Console.ReadLine();
}
}
class Sample
{
string _Name;
public string Name
{
get { return _Name; }
set { _Name = value; }
}
public override string ToString()
{
return Name;
}
}
Run Code Online (Sandbox Code Playgroud)
输出:
Some Sample Name : …Run Code Online (Sandbox Code Playgroud) 为什么使用on和off宏会产生问题.我是新手使用c宏.宏声明是否正确或代码是否存在其他问题.请帮忙 ??
#include<stdio.h>
#include<stdint.h>
#define ONE 1; // OR BY 1 [ 0 0 0 0 0 0 0 1 ] TO insert 1 at LSB position
#define TWO_FIVE_FOUR 254; // AND BY 254 [ 1 1 1 1 1 1 1 0 ] TO insert 0 at LSB position
#define on(x) (x|ONE)
#define off(x) (x & TWO_FIVE_FOUR)
int main()
{
uint8_t a=53;
printf("\nValue of byte a : %d",a );
printf("\nValue of byte b : %d",on(a)); //Error
printf("\nValue of byte …Run Code Online (Sandbox Code Playgroud) float f=44268/107402;
printf("\n%f",f);
Run Code Online (Sandbox Code Playgroud)
输出:
0.000000
怎么会发生这种情况!
我在win 7上使用了pelles c ide.
我想在c中创建一个文件(.bmp)的精确副本
#include<stdio.h>
int main()
{
FILE *str,*cptr;
if((str=fopen("org.bmp","rb"))==NULL)
{
fprintf(stderr,"Cannot read file\n");
//return 1;
}
if((cptr=fopen("copy.bmp","wb"))==NULL)
{
fprintf(stderr,"Cannot open output file\n");
//return 1;
}
fseek(str, 0, SEEK_END);
long size=ftell(str);
printf("Size of FILE : %.2f MB \n",(float)size/1024/1024);
char b[2];
for(int i=0;i<size;i++)
{
fread(b,1,1,str);
fwrite(b,1,1,cptr);
}
fseek(cptr, 0, SEEK_END);
long csize=ftell(str);
printf("Size of created FILE : %.2f MB \n",(float)csize/1024/1024);
fclose(str);
fclose(cptr);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
虽然它创建了一个大小相同的文件,但是在尝试查看新创建的位图副本时,Windows会引发错误.为什么会这样?
我有3个java类.堆栈 - 实现堆栈.Stackserver - 实现基于用户操作创建Stack对象并返回结果的服务器StackClient - 实现发送操作请求并从服务器接收reslut的客户端.
动作是推,弹出,显示和退出.
当我输入动作时,它总是说无效操作.任何人都可以在程序中找到错误吗?
堆栈类
public class Stack
{
private int maxSize;
private int[] stackArray;
private int top,i;
public Stack(int s)
{
maxSize = s;
stackArray = new int[maxSize];
top = -1;
}
public void push(int j)
{
stackArray[++top] = j;
}
public String display()
{
i=top;
String s="";
while(i>=0)
{
s=s+" "+stackArray[i--];
}
return s;
}
public int pop()
{
return stackArray[top--];
}
public int peek()
{
return stackArray[top];
}
public boolean isEmpty()
{ …Run Code Online (Sandbox Code Playgroud) do
{
swap=false;
for(int i=0; i<256; i++)
{
if(pd[i]<pd[i+1])
{
int temp=pd[i];
pd[i]=pd[i+1];
pd[i+1]=temp;
swap=true;
}
}
}
while(swap);
Run Code Online (Sandbox Code Playgroud)
它只能正确返回前两个结果,其余为0.我正在排序浮点数.
c# ×5
c ×4
wpf ×2
bubble-sort ×1
inheritance ×1
java ×1
oracle ×1
pelles-c ×1
plsql ×1
sockets ×1