อ่านในภาษาอังกฤษ แก้ไข

แชร์ผ่าน


ResourceManager.GetObject Method

Definition

Returns the value of the specified non-string resource for the current culture.

Overloads

GetObject(String)

Returns the value of the specified non-string resource.

GetObject(String, CultureInfo)

Gets the value of the specified non-string resource localized for the specified culture.

GetObject(String)

Source:
ResourceManager.cs
Source:
ResourceManager.cs
Source:
ResourceManager.cs

Returns the value of the specified non-string resource.

C#
public virtual object? GetObject(string name);
C#
public virtual object GetObject(string name);

Parameters

name
String

The name of the resource to get.

Returns

The value of the resource localized for the caller's current culture settings. If an appropriate resource set exists but name cannot be found, the method returns null.

Exceptions

The name parameter is null.

No usable set of localized resources has been found, and there are no default culture resources. For information about how to handle this exception, see the "Handling MissingManifestResourceException and MissingSatelliteAssemblyException Exceptions" section in the ResourceManager class topic.

The default culture's resources reside in a satellite assembly that could not be found. For information about how to handle this exception, see the "Handling MissingManifestResourceException and MissingSatelliteAssemblyException Exceptions" section in the ResourceManager class topic.

Remarks

For more information about this API, see Supplemental API remarks for ResourceManager.GetObject.

See also

Applies to

.NET 9 และรุ่นอื่นๆ
ผลิตภัณฑ์ เวอร์ชัน
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

GetObject(String, CultureInfo)

Source:
ResourceManager.cs
Source:
ResourceManager.cs
Source:
ResourceManager.cs

Gets the value of the specified non-string resource localized for the specified culture.

C#
public virtual object? GetObject(string name, System.Globalization.CultureInfo? culture);
C#
public virtual object GetObject(string name, System.Globalization.CultureInfo culture);

Parameters

name
String

The name of the resource to get.

culture
CultureInfo

The culture for which the resource is localized. If the resource is not localized for this culture, the resource manager uses fallback rules to locate an appropriate resource.

If this value is null, the CultureInfo object is obtained by using the CurrentUICulture property.

Returns

The value of the resource, localized for the specified culture. If an appropriate resource set exists but name cannot be found, the method returns null.

Exceptions

The name parameter is null.

No usable set of resources have been found, and there are no default culture resources. For information about how to handle this exception, see the "Handling MissingManifestResourceException and MissingSatelliteAssemblyException Exceptions" section in the ResourceManager class topic.

The default culture's resources reside in a satellite assembly that could not be found. For information about how to handle this exception, see the "Handling MissingManifestResourceException and MissingSatelliteAssemblyException Exceptions" section in the ResourceManager class topic.

Remarks

For more information about this API, see Supplemental API remarks for ResourceManager.GetObject.

Thread Safety

The GetObject(String, CultureInfo) method is thread safe.

See also

Applies to

.NET 9 และรุ่นอื่นๆ
ผลิตภัณฑ์ เวอร์ชัน
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1