This(英語單詞)

This(英語單詞)

本詞條是多義詞,共2個義項
更多義項 ▼ 收起列表 ▲

This,英語單詞,發音:[英][ðɪs][美][ðɪs]。常翻譯為:這,這么。

基本介紹

  • 外文名:This
  • 屬性:英語單詞
  • 其他:煙名
  • 翻譯:這, 本,這么
  • java:關鍵字
例句,詞語用法,辭彙搭配,計算機中,AS3.0,

例句

This ship docked this morning.
這條船是今天早上靠的碼頭。
.This new approach is
新方案有:
.A downpour this afternoon
下午有瓢潑大雨
.For this particular purpose
為某一特別目的
.Move this heavy box
把這重箱子挪動
Pecified by doing this
將某物擠成某形狀、大小等
Person who does this
(使人感到)憂愁的,沮喪的
.Shop operating this system
現款自運商店(實行上述制度的商店)
.Wish this delay tolerate
望原諒我的延誤。
.This work continues. This story goes on.
這項工作必須繼續下去。

詞語用法

adj.(形容詞)this用作形容詞作“這”解時,用於修飾表示在時間、地點、想法上更接近講話者的事物或人,也可與包括現在的日子或一段時間的詞語連用。
“this+one's+ n. ”是一種簡潔的文體,有強調意味; “this+基數詞+時間名詞”表示一段時間。this可與of短語連用,後接名詞性物主代詞名詞所有格
pron.(代詞)this用作代詞可用以指敘述中的人或事物,即指前面提到過的人或事物或下文提及的事物; this一般作主語時才指人; 在電話用語中, this用來指代自己。
當陳述部分的主語是this時,附加疑問部分的主語須用it。

辭彙搭配

in this day and age當今
this and that 又是這個
... ... to this day至今
at this rate照這樣下去
this day week上星期的今天
... with this這樣說了就
in this regard在這點上
this here這, 這個
this day month一個月前的今天,一個
... at this moment in time現在
all this while這一陣子
This is just between you and me.這只是我們兩個之間的
... selfsame完全一樣的
by this這時
this instant即刻
by this time到這時
like this象這樣
this much是這樣(這么多
... from this day forth從今天起
a better man never trod this earth沒有比他更好的人...

計算機中

C#中的this
C#中的保留字this僅限於在構造函式,類的方法和類的實例中使用。
* 在類的構造函式中出現的this作為一個值類型,它表示對正在構造的對象本身的引用
* 在類的方法中出現的this作為一個值類型,表示對調用該方法的對象的引用
* 在結構的構造函式中出現的this作為一個變數類型,表示對正在構造的結構的引用
* 在結構的方法中出現this作為一個變數類型,表示對調用該方法的結構的引用
* 被用來區分類成員及本地的成員
* 除此之外,其他地方使用this保留字都是不合法的。
一.this的常用用途:
1.限定被相似的名稱隱藏的成員
eg:public Employee(string name, string alias)
{
this.name= name;
this.alias = alias;
}
2.將對象作為參數傳遞到其他方法
eg:CalcTax(this);
3.聲明索引器
eg:public int this [int param]
{
get { return array[param]; }
set { array[param] = value; }
}
二.典型示例
在本例中,this 用於限定 Employee 類成員 name 和 alias,它們都被相似的名稱隱藏。this 還用於將對象傳遞到屬於其他類的方法 CalcTax。
// keywords_this.cs
// this example
using System;
class Employee
{
private string name;
private string alias;
private decimal salary = 3000.00m;
// Constructor:
public Employee(string name, string alias)
{
// Use this to qualify the fields, name and alias:
this.name= name;
this.alias = alias;
}
// Printing method:
public void printEmployee()
{
Console.WriteLine("Name: {0}\nAlias: {1}", name, alias);
// Passing the object to the CalcTax method by using this:
Console.WriteLine("Taxes: {0:C}", Tax.CalcTax(this));
}
public decimal Salary
{
get { return salary; }
}
}
class Tax
{
public static decimal CalcTax(Employee E)
{
return 0.08m * E.Salary;
}
}
class MainClass
{
static void Main()
{
// Create objects:
Employee E1 = new Employee("John M. Trainer", "jtrainer");
// Display results:
E1.printEmployee();
}
}
輸出:
Name: John M. Trainer
Alias: jtrainer
Taxes: $240.00
C++中的this
this是關鍵字,屬於實體(entity),是一個指針右值,只能在class,struct, 和union類型中的非靜態成員函式/函式模版class指針訪問,指向被調成員所屬的對象。靜態成員中無法使用this指針。
this
this->member-identifier
一.備註:
1.一個對象的this指針並不是這個對象自身的一部分;當一個非靜態成員函式調用一個對象時,對象的地址就以隱藏參數的形式通過編譯器傳遞給了函式。
eg:
myDate.setMonth(3);
也可以這樣表達:
setMonth(&myDate,3);
2.對象的地址可以通過this指針在成員函式中傳遞。指稱非靜態成員時,大多數情況下可以隱含this,這是合法的。儘管不必要,但在訪問class的成員時顯式使用this->或(*this).有助於避免存在和成員同名的參數時的誤用。此外,繼承的基類若依賴於模版類型參數,訪問其中的成員必須顯式使用this以在實例化後指定適當的成員,否則名稱查找並不會在依賴類型中查找成員。
eg:
void Date::setMonth( int mn )
{
month = mn; // These three statements
this->month = mn; // are equivalent
(*this).month = mn;
}
3.*this這種表達形式通常是用來在成員函式中返回當前對象。
eg:
return *this;
4.this指針有時候也用來防止自我引用。
eg:
if (&Object != this) {
// do not execute in cases of self-reference
}
二.典型示例
// this_pointer.cpp
// VC++: compile with: /EHsc
#include <iostream>
#include <cstring>
using namespace std;
class Buf
{
Buf( char* szBuffer,size_tsizeOfBuffer );
Buf& operator=( const Buf & );
void Display() { cout << buffer << endl; }
private:
char* buffer;
size_tsizeOfBuffer;
};
Buf::Buf( char* szBuffer,size_tsizeOfBuffer )
{
sizeOfBuffer++; // account for a NULL terminator
buffer = new char[ sizeOfBuffer ];
if (buffer)
{
strcpy_s( buffer, sizeOfBuffer, szBuffer );
sizeOfBuffer = sizeOfBuffer;
}
}
Buf& Buf::operator=( const Buf &otherbuf )
{
if( &otherbuf !=this)
{
if (buffer)
delete [] buffer;
sizeOfBuffer = strlen( otherbuf.buffer ) + 1;
buffer = new char[sizeOfBuffer];
strcpy_s( buffer, sizeOfBuffer, otherbuf.buffer );
}
return*this;
}
int main()
{
Buf myBuf( "my buffer", 10 );
Buf yourBuf( "your buffer", 12 );
// Display 'my buffer'
myBuf.Display();
// assignment opperator
myBuf = yourBuf;
// Display 'your buffer'
myBuf.Display();
}
輸出:
my buffer
your buffer
Java中的this
Java中的this關鍵字是對類的當前實例的引用,它只能在實例的上下文中使用。
以下代碼顯示如何使用this關鍵字:
public class Main {  int varA = 1;  int varB = varA; // Assign value of varA to varB  int varC = this.varA; // Assign value of varA to varC}例子:下面的代碼顯示了如何使用this關鍵字來引用一個實例變數,它的名字被一個局部變數隱藏。public class Main {  int num = 2014; // An instance variable  void printNum(int num) {    System.out.println("Parameter num: " + num);    System.out.println("Instance variable num: " + this.num);  }  public static void main(String[] args) {    Main tt6 = new Main();    tt6.printNum(2000);  }}上面的代碼生成以下結果:
我們可以使用關鍵字this來限定實例方法名稱。以下代碼顯示使用關鍵字this調用m2()方法的m1()方法。
This(英語單詞)
public class Main {  void m1() {    // Invoke the m2() method    this.m2(); // same as "m2();"  }  void m2() {    // do something  }}

AS3.0

this在一個類裡面是指代類‘自己’,通過這個指向,可以訪問類內部的屬性、方法(在外部只能訪問公用的)。this,在代碼里,指向舞台,可以訪問舞台的元素。

相關詞條

熱門詞條

聯絡我們