JBTALKS.CC

标题: 折磨(一) 第二的又写到一半 忙~~~~~ [打印本页]

作者: goodday    时间: 2008-12-6 06:23 PM
标题: 折磨(一) 第二的又写到一半 忙~~~~~
你们要从基础学咯

ok 我这边给你们的是 .net 的 写法

基础是 几个

c# 是 case sensitivity 的 S != s
vb.net 是没有分的 S = s

注解 或 marking

c#

一行的

// this is c#

多行的

/*  this
     is
      C#
*/

vb.net

' this is vb.net
REM this is vb.net

==============================
c# 是以 ;   来区分是不是 下一行了
vb 直接 enter

看语法

c#
==============================
string A;
string B = A ;

// 一行的写法
mystring = mystring1 + mystring2 + mystring3;
// 两行的写法
mystring = mystring1 + mystring2 +
                    mystring3;
//三行的写法
mystring = mystring1 +
                    mystring2 +
                    mystring3;
==============================
c# 只要没 ; 就是当成同一行。

vb.net
==============================
dim A as string
dim B as string = A

' 一行的写法
mystring = mystring1 + mystring2 + mystring3
' 两行的写法
mystring = mystring1 + mystring2 + _
                    mystring3
' 三行的写法
mystring = mystring1 + _
                    mystring2 + _
                    mystring3
==============================
vb.net 的只要enter  就是下一行咯 只能用 _ 来 接下一行是同行


block structure
c# 的是
{ }
==============================

if (a == b)
{
     'abc
}

public bool goodday()
{
     'abc
}

==============================
vb.net
end if end case  end sub end function
==============================

if a = b then
     'abc
End if

public function goodday() as boolean
     'abc
end function

资料类型  data type


Size (bytes)Visual Basic.netC#.netCommon Runtime LanguageValue Range
01 Byte byteSystem.Byte0 to 255
01 (Not Implemented) sbyteSystem.Sbyte-128 to 127
02 Boolean boolSystem.BooleanTrue or False only
02 Char charSystem.Char0 to 65535
02 Short shortSystem.Int16-32,768 to 32,767.
02 (Not Implemented) ushortSystem.UInt160 to 65535
04 Integer intSystem.Int32-2,147,483,648 to 2,147,483,647
04 (Not Implemented) uintSystem.Uint320 to 4294967295
04 Single floatSystem.Single-3.4028235E+38 to -1.401298E-45 for negative values; 1.401298E-45 to 3.4028235E+38 for positive values.
04 Object objectSystem.ObjectAny type can be stored in a variable of type Object.
08 Date DateTimeSystem.DateTime0:00:00 on January 1, 0001 through 11:59:59 PM on December 31, 9999.
08 Long longSystem.Int64-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
08 (Not Implemented) ulongSystem.UInt640 to 18446744073709551615
08 Double doubleSystem.Double-1.79769313486231570E+308 to -4.94065645841246544E-324 for negative values; 4.94065645841246544E-324 through 1.79769313486231570E+308 for positive values.
16 Decimal decimalSystem.Decimal0 to +/-79,228,162,514,264,337,593,543,950,335 with no decimal point;0 through +/-7.9228162514264337593543950335 with 28 places to the right of the decimal; smallest nonzero number is +/-0.0000000000000000000000000001 (+/-1E-28).
Varies structure structSystem.ValueTypeEach member of the structure has a range determined by its data type and independent of the ranges of the other members.
Varies String stringSystem.String0 to approximately 2 billion Unicode characters


[ 本帖最后由 goodday 于 2008-12-7 11:35 AM 编辑 ]
作者: goodday    时间: 2008-12-6 06:25 PM
data type 是很基础又很重要的

如果你不明白 很难会写个有效率 的系统

好像 boolean
你的 东西 如果只有
对错  是或不是 可以 不可以

那你用 boolean 咯

好像 integer
他的 是 由

-2,147,483,648

2,147,483,647

你要用的如果不到 20亿 那你大可用它咯

但如果你用到 20亿 以上
你就得用 long

他是由

-9,223,372,036,854,775,808

9,223,372,036,854,775,807.

我肯定你够用啦

否则
overflow exception

你要算什么 那么大哦
bill gate 都没那个数字的身家

如果你一直 用 long 你就浪费很多的 ram 啦
你的program 越用越慢 因为一直要调用资源 和 回流资源
释放 和 回流都很慢 大嘛

如果你的server 或pc 有 128GB Ram 我没话好说
不用动用那么多的page file 或 swap patition

好啦 那么多的废话

回主题

DateTime
这个的 DataType 很复杂
=========================================
vb.net
=========================================

dim ATime as DateTime = new DateTime(2008,01,01,00,00,00)
dim BTime as DateTime = DateTime.Now()
dim CTime as String = DateTime.Now.Year()
dim DTime as DateTime = DateTime.Now.AddDays(100)

=========================================
c#
=========================================

DateTime  ATime = new DateTime(2008,01,01,00,00,00);
DateTime  BTime = DateTime.Now();
String         CTime = DateTime.Now.Year();
DateTime  DTime = DateTime.Now.AddDays(100);

=========================================
以上的答案
=========================================
ATime  = 01/01/2008 12:00:00 am
BTime  = 现在的时间
CTime  = 2008
DTime  = 现在的日期 再加 100 天

有用的 属性

=========================================
C#
=========================================
DateTime NowTime;

=========================================
VB.net
=========================================
Dim NowTime as DateTime

NowTime.Now       =  现在的时间 --〉 01/01/2008 3:15:00pm
NowTime.Today    =  现在的日期 -->    01/01/2008 12:00:00 am

NowTime.Year               = 2008
NowTime.Date               =  
NowTime.Day                = 13
NowTime.Hour              =12
NowTime.Minute           =30
NowTime.Second         =30
NowTime.Millisecond  =


Table 1.1 - Standard Format Characters
Format CharacterFormat Pattern
dMM/dd/yyyy
Ddddd, MMMM dd, yyyy
fdddd, MMMM dd, yyyy HH:mm
Fdddd, MMMM dd, yyyy HH:mm:ss
gMM/dd/yyyy HH:mm
GMM/dd/yyyy HH:mm:ss
m, MMMMM dd
r, Rddd, dd MMM yyyy HH':'mm':'ss 'GMT'
syyyy-MM-dd HH:mm:ss
t HH:mm
THH:mm:ss
uyyyy-MM-dd HH:mm:ss
Udddd, MMMM dd, yyyy HH:mm:ss
y, YMMMM, yyyy
Table 1.2 - List of patterns you can use to create custom formatting
Format PatternDescription
dThe day of the month. Single-digit days will not have a leading zero.
dd The day of the month. Single-digit days will have a leading zero.
dddThe abbreviated name of the day of the week
ddddThe full name of the day of the week
M The numeric month. Single-digit months will not have a leading zero.
MMThe numeric month. Single-digit months will have a leading zero.
MMM The abbreviated name of the month
MMMM The full name of the month
y The year without the century. If the year without the century is less than 10, the year is displayed with no leading zero.
yy The year without the century. If the year without the century is less than 10, the year is displayed with a leading zero.
yyyy The year including the century in four digits.
gg The period or era. This pattern is ignored if the date to be formatted does not have an associated period or era string.
h The hour in a 12-hour clock. Single-digit hours will not have a leading zero.
hh, hh* The hour in a 12-hour clock. Single-digit hours will have a leading zero.
HThe hour in a 24-hour clock. Single-digit hours will not have a leading zero.
HH, HH* The hour in a 24-hour clock. Single-digit hours will have a leading zero.a
mThe minute. Single-digit minutes will not have a leading zero.
mm, mm* The minute. Single-digit minutes will have a leading zero.
s The second. Single-digit seconds will not have a leading zero.
ss, ss* The second. Single-digit seconds will have a leading zero.
t The first character in the AM/PM designator
tt, tt* The AM/PM designator
z The timezone offset (hour only). Single-digit hours will not have a leading zero.
zz The timezone offset (hour only). Single-digit hours will have a leading zero.
zzz, zzz* The full timezone offset (hour and minutes). Single-digit hours and minutes will have leading zeros.
:The default time separator
/ The default date separator
% c Where c is a standard format character. Displays the standard format pattern associated with the format character.
\ c Where c is any character. Displays the character literally.





http://www.dotnetjunkies.ddj.com/Tutorial/9D1C5FBF-FE27-42EA-B8C3-058FF295D822.dcik

http://blog.darkthread.net/blogs/darkthreadtw/archive/2007/04/30/tips-net-datetime-formating.aspx

[ 本帖最后由 goodday 于 2008-12-7 11:33 AM 编辑 ]
作者: goodhermit95    时间: 2008-12-6 07:18 PM
给那些喜欢喜欢就说要学的人看了直接晕倒
原来C# 不用 _ 的
还有多余的设写法
Dim a As String
Dim B As String
a = B
多余的啦,凑行数专用

C#的等于是 == 啊?
那个什么byte的,我都没有用,只要是Byte,ushort等等都用String搞定
打太多string玩GAME打Strong都会打成String

很好的折磨(给新手)
尤其是买菜的
作者: Super-Tomato    时间: 2008-12-6 11:00 PM
原帖由 goodhermit95 于 2008-12-6 07:18 PM 发表
给那些喜欢喜欢就说要学的人看了直接晕倒
原来C# 不用 _ 的
还有多余的设写法
Dim a As String
Dim B As String
a = B
多余的啦,凑行数专用

C#的等于是 == 啊?
那个什么byte的,我都没有用, ...



data type 是一個 programmer 必須了解的基礎, 適當的使用可以減少記憶體上的佔用
ushort 是數字類型無法以 String 來代替


新手不要單單只是背起這些 data type, 必須了解為甚麼 short 和 ushort 是 4 bytes, 而為何起範圍是 65535 的長度, 還有怎麼計算出來等
這些就等 goodday 慢慢解釋給你們聽了
作者: ~Zero    时间: 2008-12-6 11:49 PM
我觉得... 最最基础是教人怎样 install, compile, run 先...
教人怎样写个简单的 hello world...
作者: MercyGodlikE    时间: 2008-12-7 02:00 PM
公说公有理,婆说婆有理
作者: ★笨☆天使    时间: 2008-12-8 12:46 AM
这个好...怎样收起啦??(终于有我看得懂的东西了 )
怕给你删掉我要看的时候没得看
作者: Jay1515Jay    时间: 2009-1-9 10:56 AM
标题: 回复 #7 ★笨☆天使 的帖子
ctrl+s save这个网页
好贴em0036 顶

vb的
end if end case  end sub end function
和c#的{}比好像vb要按很多字==
作者: 丧送狂曲    时间: 2009-1-9 11:34 AM
楼主如果他们没有什么逻辑来看待的话我看也很难明白不过你给我们这些会一些的看就很容易明白
不过你的苦心我深深佩服...完成应该升精华吧em0011
作者: Dhilip89    时间: 2009-1-9 04:47 PM
我又来了,最近少上JBTalks了

block structure
c# 的是
{ }
==============================

if (a == b)
{
     'abc
}

public bool goodday()
{
     'abc
}


'abc 应该是 //abc 吧?
作者: goodhermit95    时间: 2009-1-9 09:53 PM
标题: 回复 #8 Jay1515Jay 的帖子
很少人直接这样弄C#的咯
end function打 en fun 就够了
作者: Jay1515Jay    时间: 2009-1-10 02:19 AM
标题: 回复 #11 goodhermit95 的帖子
我copy楼主的
vb的风格我一点都不懂
作者: goodday    时间: 2009-1-10 03:08 AM
原帖由 Jay1515Jay 于 2009-1-9 10:56 AM 发表
ctrl+s save这个网页
好贴em0036 顶

vb的
end if end case  end sub end function
和c#的{}比好像vb要按很多字==



当你打完

if (abc)


按一按 enter 就 自己 变成

if (abc) then
   
end if  

====================

then
<空行>
end if

自己完成的


写 vb 会比 c# 快很多

c# 比 vb 好看很多
作者: goodday    时间: 2009-1-10 03:10 AM
原帖由 Dhilip89 于 2009-1-9 04:47 PM 发表
我又来了,最近少上JBTalks了



'abc 应该是 //abc 吧?



哈哈 你是第一个主意到的

我真的写错了
作者: Jay1515Jay    时间: 2009-1-10 03:29 AM
原帖由 goodday 于 2009-1-10 03:08 AM 发表



当你打完

if (abc)


按一按 enter 就 自己 变成

if (abc) then
   
end if  

====================

then

end if

自己完成的


写 vb 会比 c# 快很多

c# 比 vb 好看很多

都有各自的好处em0006
作者: goodhermit95    时间: 2009-1-10 09:35 AM
标题: 回复 #15 Jay1515Jay 的帖子
我是顶不顺,因为那个问题就放弃VB = =
作者: Jay1515Jay    时间: 2009-1-10 03:15 PM
原帖由 goodhermit95 于 2009-1-10 09:35 AM 发表
我是顶不顺,因为那个问题就放弃VB = =

programming熟了我会学其它语言
不可能单单学一个的
作者: DevilBat81    时间: 2009-1-11 09:34 PM
超久没写了,以前开始学每个language时开始学的。
作者: sumplayer    时间: 2009-1-12 10:22 AM
zzz= =樓主看到暈不懂你在教什么東西可以說一下嗎???我也是要學學下的!!!哈哈哈em0013




欢迎光临 JBTALKS.CC (https://www.jbtalks.cc/) Powered by Discuz! X2.5